[SciPy-user] Mlab doesn't work

Gael Varoquaux gael.varoquaux@normalesup....
Wed Jun 18 08:17:29 CDT 2008


On Wed, Jun 18, 2008 at 02:07:08PM +0200, Alexander Borghgraef wrote:
> After commenting out nearly everyting, it seemed that there was some
> incompatibility between mlab and pylab (which I use for 2D plotting).
> For example, this works fine:

>   from enthought.mayavi import mlab
>   from scipy import lena
>   mlab.surf(lena())

> But this results in the above mentioned error:

>   import pylab
>   from enthought.mayavi import mlab
>   from scipy import lena
>   mlab.surf(lena())

Interesting. I was not aware of this problem, but it partly makes sense.
The problem is that pylab, as you are probably using it, uses the TK
toolkit, whereas mayavi uses the Wx. Running both event loops in the same
time results in a nice segfault due to race conditions.

The solution is to have pylab use the Wx event loop. You can do this by
doing (before importing pylab):
"""
import matplotlib
matplotlib.use('WxAdd')
"""
Alternatively, in the recent versions of ipython, Fernando has made sure
that if you use both the "-pylab" switch and the "-wthread" switch to
ipython, this is enforced, and mayavi works fine.

HTH,

Gaël


More information about the SciPy-user mailing list