Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26487
| Subject | Re: trouble with pyplot in os x |
|---|---|
| From | "William R. Wing (Bill Wing)" <wrw@mac.com> |
| Date | 2012-08-04 09:11 -0400 |
| References | <3a2464ec-8fbc-4c45-8509-6861031f9204@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2936.1344089518.4697.python-list@python.org> (permalink) |
On Aug 3, 2012, at 11:12 PM, Eric <einazaki668@yahoo.com> wrote:
> I'm just starting to futz around with matplotlib and I tried to run this
> example from the matplotlib doc page (it's the imshow() example):
>
> import numpy as np
> import matplotlib.cm as cm
> import matplotlib.mlab as mlab
> import matplotlib.pyplot as plt
>
> delta = 0.025
> x = y = np.arange(-3.0, 3.0, delta)
> X, Y = np.meshgrid(x, y)
> Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
> Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
> Z = Z2-Z1 # difference of Gaussians
>
> im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
> origin='lower', extent=[-3,3,-3,3])
>
> plt.show()
>
>
OK
>
> I get the following error:
>
> Exception in Tkinter callback
> Traceback (most recent call last):
> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1410, in __call__
> return self.func(*args)
> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 248, in resize
> self.show()
> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 252, in draw
> tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/tkagg.py", line 19, in blit
> tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))
> TclError
>
>
This looks as though you are running the latest python from python.org, not the pre-installed python from Apple (that's good).
>
> I'm using Python 2.7.3 on OS X 10.6.8 and I'm invoking python by doing
> "arch -i386 python" because matplotlib doesn't do 64-bit. Has anyone
> else seen this? Does anyone know why this is happening? It looks
> like a problem with tkinter but beyond that I haven't a clue. And,
> finally, any ideas as to how to make it behave?
>
I DON'T know how tk is getting mixed into this, it shouldn't be. But I think I can tell you how to get matplotlib working...
Matplotlib DOES do 64-bit, the problem is numpy, which as you download in binary form does not. But, if you copy the bash script here:
https://raw.github.com/fonnesbeck/ScipySuperpack/master/install_superpack.sh
it will download the sources and build a 64-bit numpy, which will then give you a default 64-bit full package of python, numpy, and matplotlib.
That's what I've done, and my system runs the demo you listed in your post with no problems.
> TIA,
> eric
> --
> http://mail.python.org/mailman/listinfo/python-list
Good luck,
-Bill
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
trouble with pyplot in os x Eric <einazaki668@yahoo.com> - 2012-08-03 20:12 -0700
Re: trouble with pyplot in os x "William R. Wing (Bill Wing)" <wrw@mac.com> - 2012-08-04 09:11 -0400
Re: trouble with pyplot in os x Eric <einazaki668@yahoo.com> - 2012-08-04 13:45 -0700
Re: trouble with pyplot in os x Eric <einazaki668@yahoo.com> - 2012-08-04 13:45 -0700
csiph-web