Demo does not work on Snow Leopard

Hi,

I installed matplotlib-0.99.3-py2.6-macosx10.6.dmg on MacOS X 10.6.3, python 2.6.5. But I get an error when running the histogram example from
http://matplotlib.sourceforge.net/examples/api/histogram_demo.html

Exception in Tkinter callback
Traceback (most recent call last):
   File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/Tkinter.py", line 1410, in __call__
     return self.func(*args)
   File "/Library/Python/2.6/site-packages/matplotlib/backends/backend_tkagg.py", line 212, in resize
     self.show()
   File "/Library/Python/2.6/site-packages/matplotlib/backends/backend_tkagg.py", line 216, in draw
     tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
   File "/Library/Python/2.6/site-packages/matplotlib/backends/tkagg.py", line 19, in blit
     tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))
TclError

Would anybody know what's wrong?

Thanks,

Hana

2010/6/17 Hana Sevcikova <hana@...2195...>:

I installed matplotlib-0.99.3-py2.6-macosx10.6.dmg on MacOS X 10.6.3,
python 2.6.5. But I get an error when running the histogram example from
http://matplotlib.sourceforge.net/examples/api/histogram_demo.html

Have you compiled Python yourself? I'm asking because Python 2.6.5
from Python.org is maybe linked against another Tcl/Tk than it links
to when you compile yourself. (I guess the matplotlib._tkagg module
does some patchy things.)

Friedrich

I installed python-2.6.5-macosx10.3-2010-03-24.dmg from python.org. (Sorry, I should have mentioned that before.)

Hana

···

On 6/18/10 7:11 AM, Friedrich Romstedt wrote:

2010/6/17 Hana Sevcikova<hana@...2195...>:
   

I installed matplotlib-0.99.3-py2.6-macosx10.6.dmg on MacOS X 10.6.3,
python 2.6.5. But I get an error when running the histogram example from
http://matplotlib.sourceforge.net/examples/api/histogram_demo.html
     

Have you compiled Python yourself? I'm asking because Python 2.6.5
from Python.org is maybe linked against another Tcl/Tk than it links
to when you compile yourself. (I guess the matplotlib._tkagg module
does some patchy things.)

Friedrich

2010/6/18 Hana Sevcikova <hana@...2195...>:

I installed python-2.6.5-macosx10.3-2010-03-24.dmg from python.org. (Sorry,
I should have mentioned that before.)

Hmm, could you please run:

otool -L /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so
otool -L /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/_tkagg.so

and post the output (copy to clipboard with | pbcopy)

Friedrich

# otool -L /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so:
     /Library/Frameworks/Tcl.framework/Versions/8.4/Tcl (compatibility version 8.4.0, current version 8.4.19)
     /Library/Frameworks/Tk.framework/Versions/8.4/Tk (compatibility version 8.4.0, current version 8.4.19)
     /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.10)

I needed to modify the path in the second command, since matplotlib was installed into /Library/Python/2.6/site-packages. Could that be the issue? Anyway, here is the output:

# otool -L /Library/Python/2.6/site-packages/matplotlib/backends/_tkagg.so
/Library/Python/2.6/site-packages/matplotlib/backends/_tkagg.so:
     /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
     /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.1)
     /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
     /System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl (compatibility version 8.5.0, current version 8.5.7)
     /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk (compatibility version 8.5.0, current version 8.5.7)

I see there are some compatibility issues. What would be the best way to deal with it?

Thanks,
Hana

···

On 6/18/10 2:07 PM, Friedrich Romstedt wrote:

2010/6/18 Hana Sevcikova<hana@...2195...>:
   

I installed python-2.6.5-macosx10.3-2010-03-24.dmg from python.org. (Sorry,
I should have mentioned that before.)
     

Hmm, could you please run:

otool -L /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_tkinter.so
otool -L /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/_tkagg.so

and post the output (copy to clipboard with | pbcopy)

Friedrich

Many apologises for the slow response ...

I'm quite convinced the path is not an issue.

2010/6/19 Hana Sevcikova <hana@...2195...>:

I see there are some compatibility issues. What would be the best way to
deal with it?

This should be the issue. I think usually the matplotlib binaries are
linked against the same libraries as the Python binaries to avoid such
trouble, but for the 10.6 issue this went wrong somehow? I don't
know.

A possibility would be to compile Python and matplotlib yourself.
This can, for matplotlib, be somewhat troublesome. There is a
recommended way via the make.osx script, and "my" way via tweaking of
the config files. The recommended way downloads freetype2 etc. into a
local directory and does afaik hard linking, "my" way links it the
usual dynamic way against system-wide installed libraries. The
make.osx way is way from perfect, but it should work, albeit I
personally like the other way much more, since it appears much more
clean to me. Tell me what you prefer. If you prefer "my" way, I will
give you detailed instructions, with the make.osx way I'm neither
comfortable nor acquainted, maybe John can help you then. There's
also a recent thread about building matplotlib on Mac (10.6 if I'm not
mistaken) with make.osx.

Friedrich