I am trying to install MayaVi on my computer. I'm on a MacBook Air with OS X 10.6.8, 4 GB RAM.
My python and most of my stack is built through Homebrew or pip. In particular this is true for python2.7, ipython, Qt4, numpy, scipy, vtk, etc. VTK was installed with --python and --qt-extern flags in Homebrew, and all the builds were fine. I do not have wxPython installed, as I failed to get it working through pip, manual building, or the binaries.
If I run
ipython -q4thread, I cannot successfully execute
from mayavi import mlab as I get an error related to usage of two different APIs for PyQt: http://groups.google.com/group/spyderlib/browse_thread/thread/36a35baec74ca144
However, if I run
ipython alone, I can successfully run
from mayavi import mlab. Then I try to follow this example: http://github.enthought.com/mayavi/mayavi/example_using_with_scipy.html, which includes these commands:
import numpy as np def V(x, y, z): """ A 3D sinusoidal lattice with a parabolic confinement. """ return np.cos(10*x) + np.cos(10*y) + np.cos(10*z) + 2*(x**2 + y**2 + z**2) X, Y, Z = np.mgrid[-2:2:100j, -2:2:100j, -2:2:100开发者_开发百科j] from mayavi import mlab mlab.contour3d(X, Y, Z, V)
This all works fine, and I get a window that pops up and I can rotate the 3d plot etc. However, then I click on the icon to open up the pipeline, which opens another window. The tutorial then says to double-click on the "isosurface" to change its properties. As soon as I do that, I get a reproducible segmentation fault.
I have no idea how to begin to figure out what the problem is.
Alternatively, I can run MayaVi from the command line:
mayavi2, and the GUI pops up. When I do so I get the following output:
Warning: Unable to import the wx backend for pyface due to traceback: Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/toolkit.py", line 45, in _init_toolkit be = import_toolkit(tk) File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/toolkit.py", line 31, in import_toolkit __import__(be + 'init') File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/ui/wx/init.py", line 14, in <module> import wx ImportError: No module named wx
Although the GUI does pop up, if I try to do any operation, I get a segfault.
Please let me know if you have any thoughts on troubleshooting this, or perhaps guidance on reinstalling the package successfully.
I also have a MacBook Air with OS X 10.7.4 (Lion). I spent a lot of time back in February to get mayavi working, eventually succeeding to a point where I could produce scientific plots. That still means that some of the examples and tests wouldn't run correctly, and the GUI produced lots of error messages in the console, but didn't crash (most of the time). Now, I managed to break my Python installation (probably by upgrading numpy), so I needed to reinstall. Alas, it didn't get any easier 6 months later!
There is still no viable precompiled option. I tried the Enthought Python Distribution from here: http://www.enthought.com/repo/.epd_academic_installers. Still no 64 bit version with ETS for Mac, components are ancient, mayavi based on wxPython looks ugly and feels slow and unresponsive. So back to
pip. After a lot of trial and error, here is what worked more or less:
Hide/uninstall the broken Homebrew Python installation:
mv /usr/local/lib/python2.7/site-packages /usr/local/lib/python2.7/site-packages-old mv /usr/local/share/python /usr/local/share/python-old brew uninstall python pyqt pyside vtk
From Xcode (4.4.1), choose
llvm-gcc as the compiler (I had less success with
cd /usr/bin sudo rm cc c++ sudo ln -s gcc cc sudo ln -s g++ c++
brew install python --framework --universal
Point to the new installation:
cd /System/Library/Frameworks/Python.framework/Versions rm Current ln -s /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/Current .
If the EPD is installed, one needs to do the same in
/Library/Frameworks/Python.framework/Versions, otherwise the EPD will take priority.
Install numpy from source (
pip 1.2 currently doesn't install
npymath.ini correctly, which will make scipy fail to build):
git clone https://github.com/numpy/numpy.git cd numpy git checkout v1.6.2 python setup.py install
Since so many packages link against numpy, I really recommend checking out an official release, 1.6.2 as of today. Next make the numpy headers visible:
cd /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 ln -s /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy .
2.3 qt, pyqt, vtk
Install qt (4.8.2) and pyqt (4.9.4):
brew install qt brew install pyqt
One can also install pyside (1.1.1)
brew install pyside
but this appears to produce more crashes with mayavi. In any case, append
.bashrc to avoid any mixups. Next install vtk (5.10.0; 5.8.0 works just as well)
brew install vtk --python --tcl --examples --qt
...and wait (compilation takes around 40 minutes). The
--qt flag isn't strictly necessary, but it doesn't harm either.
Next, download vtk data from http://www.vtk.org/files/release/5.10/vtkdata-5.10.0.tar.gz, unpack somewhere and have the
VTK_DATA_ROOT environment variable point to the
VTKData directory. Run some examples in
Launch python examples with
python <example>.py and TCL examples with
vtk <example.tcl>. Works absolutely beautifully, right? So let's see how mayavi messes it all up next...
2.4 ETS and mayavi
pip install mayavi
gets you somewhere, it appears to produce more crashes than installing the bleeding edge from github. Get https://github.com/enthought/ets/raw/master/ets.py and run
python ets.py clone
to clone the ETS git repository. You only need
envisage if you want to run
mayavi2 from the command line. So delete the other directories and do
python ets.py develop
This should allow you to run some of the examples in the repository in
mayavi/examples/mayavi by running
python <example>.py and play around with the GUI. There are lots of console errors and lots of GUI features that don't work, like selecting a LUT table. But it hopefully doesn't crash.
2.5 scipy, matplotlib, ipython
I prefer to get the bleeding edge from github for scipy and matplotlib. First install all dependencies using
git clone https://github.com/scipy/scipy.git cd scipy python setup.py install git clone https://github.com/matplotlib/matplotlib.git cd matplotlib python setup.py install
Then install ipython (0.13) using
pip. For the qtconsole install first:
pip install pygments pip install pyzmq
pip install ipython
There are a few possible ways to launch ipython for use with mayavi, depending on who controls the QT event loop:
mlab.show(): Works, but prompt may become unresponsive.
ipython --pylab=qt: Works, but "Save" dialog closes immediately.
ipython qtconsole --gui=qtor
ipython qtconsole --pylab=qt: Works.