Histogram example doesn't run

Hi,

being a complete newbie, I tried to run the simple_plot example from the website with matplotlib-0.99.0. However, I get the error message:

···

--------------------------------------------------------------------
Traceback (most recent call last):
   File "simple_plot.py", line 5, in <module>
     plot(t, s, linewidth=1.0)
   File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 2135, in plot
     ax = gca()
   File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 582, in gca
     ax = gcf().gca(**kwargs)
   File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 276, in gcf
     return figure()
   File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 254, in figure
     **kwargs)
   File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 44, in new_figure_manager
     return FigureManagerGTKAgg(canvas, num)
   File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 443, in __init__
     self.window.set_icon_from_file(window_icon)
glib.GError: Couldn't recognize the image file format for file '/usr/lib/python2.6/site-packages/matplotlib/mpl-data/images/matplotlib.svg'
--------------------------------------------------------------------

It works with 0.98.5.3. Is this a bug or could anything be wrong with my installation?

Regards,
Bernd

--
Bernd Eggink
http://sudrala.de

being a complete newbie, I tried to run the simple_plot example from the
website with matplotlib-0.99.0. However, I get the error message:

"/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtk.py",
line 443, in __init__
self.window.set_icon_from_file(window_icon)
glib.GError: Couldn't recognize the image file format for file
'/usr/lib/python2.6/site-packages/matplotlib/mpl-data/images/matplotlib.svg'
--------------------------------------------------------------------

It works with 0.98.5.3. Is this a bug or could anything be wrong with my

Christoph, is GTKAgg the default backend in the win32 installers? It
should be TkAgg. Are you creating a setp.cfg when you build your
installer, as described at

  http://matplotlib.sourceforge.net/devel/release_guide.html#packaging

For OSX and the python2.5 win32 binary I build, I use a Makefile to
create setup.cfg so I don't forget :slight_smile:

Or Bernd, did you explicitly set backend gtk in your matplotlib rc file (
http://matplotlib.sourceforge.net/faq/troubleshooting_faq.html#matplotlib-directory-location).
Which installer dd you run (exact file name if you still have it)?

Also, I recall that we patched gtk to use the png not the svg icon for
win32 -- Bernd, what does your sys.platform report::

  >> import sys
  >>> sys.platform
  'linux2'

We check in backend_gtk

    if gtk.pygtk_version < (2, 8, 0) or sys.platform == 'win32':
        icon_filename = 'matplotlib.png'
    else:
        icon_filename = 'matplotlib.svg'

so you shouldn't be hitting this bug if your platform is win32.

JDH

···

On Fri, Aug 7, 2009 at 4:10 AM, Bernd Eggink<monoped@...2723...> wrote:

John Hunter schrieb:

being a complete newbie, I tried to run the simple_plot example from the
website with matplotlib-0.99.0. However, I get the error message:

"/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtk.py",
line 443, in __init__
    self.window.set_icon_from_file(window_icon)
glib.GError: Couldn't recognize the image file format for file
'/usr/lib/python2.6/site-packages/matplotlib/mpl-data/images/matplotlib.svg'
--------------------------------------------------------------------

It works with 0.98.5.3. Is this a bug or could anything be wrong with my

Christoph, is GTKAgg the default backend in the win32 installers? It
should be TkAgg. Are you creating a setp.cfg when you build your
installer, as described at

  http://matplotlib.sourceforge.net/devel/release_guide.html#packaging

For OSX and the python2.5 win32 binary I build, I use a Makefile to
create setup.cfg so I don't forget :slight_smile:

Or Bernd, did you explicitly set backend gtk in your matplotlib rc file (
http://matplotlib.sourceforge.net/faq/troubleshooting_faq.html#matplotlib-directory-location).

No. The stack trace shows that GTKAgg is used.

Which installer dd you run (exact file name if you still have it)?

I compiled matplotlib from the sources on a Crux system, simply saying

     python setup.py build
     python setup.py install --prefix=/usr --root=$PKG

Also, I recall that we patched gtk to use the png not the svg icon for
win32 -- Bernd, what does your sys.platform report::

  >> import sys
  >>> sys.platform

Platform is 'linux2', and gtk.pygtk_version is (2, 14, 1).

To get it working, I replaced matplotlib.svg by a link to matplotlib.png (which is pretty ugly, though). Maybe the error should be catched and the .png image used as a fallback.

Regards,
Bernd

···

On Fri, Aug 7, 2009 at 4:10 AM, Bernd Eggink<monoped@...2723...> wrote:

--
Bernd Eggink
http://sudrala.de

Christoph, is GTKAgg the default backend in the win32 installers? It
should be TkAgg. Are you creating a setp.cfg when you build your
installer, as described at

Reminder to self: do not post before morning coffee. For some reason
I thought you were on windows using on of Christoph's windows
installers. Christoph, feel free to ignore this thread.

Platform is 'linux2', and gtk.pygtk_version is (2, 14, 1).

To get it working, I replaced matplotlib.svg by a link to matplotlib.png
(which is pretty ugly, though). Maybe the error should be catched and
the .png image used as a fallback.

Unfortunately, the exception glib.GError is gtk version dependent so I
can't easily catch it. I am loathe to do a blanket except catch, but
I am not sure what the alternative is here.

JDH

···

On Fri, Aug 7, 2009 at 7:47 AM, Bernd Eggink<monoped@...2723...> wrote:

I committed a change to the release branch (I did not try setting the
png if the svg failed, I just give up on the icon) -- if you could
test from the svn repo:

svn co https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_99_maint
mpl99

···

On Fri, Aug 7, 2009 at 10:34 AM, John Hunter<jdh2358@...287...> wrote:

Unfortunately, the exception glib.GError is gtk version dependent so I
can't easily catch it. I am loathe to do a blanket except catch, but
I am not sure what the alternative is here.

John Hunter schrieb:

···

On Fri, Aug 7, 2009 at 10:34 AM, John Hunter<jdh2358@...287...> wrote:

Unfortunately, the exception glib.GError is gtk version dependent so I
can't easily catch it. I am loathe to do a blanket except catch, but
I am not sure what the alternative is here.

I committed a change to the release branch (I did not try setting the
png if the svg failed, I just give up on the icon) -- if you could
test from the svn repo:

svn co https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_99_maint
mpl99

It works now, but as expected I get no icon. Not sure if I don't like my hack better...

I suspect it has to do with my glib or gtk installation (both compiled from source). Maybe I'll ask the folks there.

Thanks anyway,
Bernd

--
Bernd Eggink
http://sudrala.de

monoped wrote:

Hi,

being a complete newbie, I tried to run the simple_plot example from the
website with matplotlib-0.99.0. However, I get the error message:

--------------------------------------------------------------------
Traceback (most recent call last):
   File "simple_plot.py", line 5, in <module>
     plot(t, s, linewidth=1.0)
   File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line
2135, in plot
     ax = gca()
   File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line
582, in gca
     ax = gcf().gca(**kwargs)
   File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line
276, in gcf
     return figure()
   File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line
254, in figure
     **kwargs)
   File
"/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py",
line 44, in new_figure_manager
     return FigureManagerGTKAgg(canvas, num)
   File
"/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtk.py",
line 443, in __init__
     self.window.set_icon_from_file(window_icon)
glib.GError: Couldn't recognize the image file format for file
'/usr/lib/python2.6/site-packages/matplotlib/mpl-data/images/matplotlib.svg'
--------------------------------------------------------------------

I had the same problem, and I fixed it by installing librsvg2-gtk (which
allows GTK to use SVG). Hope this helps!

···

--
View this message in context: http://www.nabble.com/Histogram-example-doesn't-run-tp24861750p25244040.html
Sent from the matplotlib - users mailing list archive at Nabble.com.