Installing VTK and MayaVi from source
Here's a little page covering one method for installing VTK and MayaVi from source.
Platform information
This is the configuration with which I have tested this method
Platform: x86 (AMD Athlon XP)
OS: Linux 2.4.21 (SuSE 9.0)
VTK version: 4.2.4
MayaVi version: 1.3
Python version: 2.3
Tcl version: 8.4
Step-by-step guide
if there have been any previous installations, it might be a good idea to clean them out. The default location is /usr/local, and there will be VTK files in the subdirectories. Removing them will help with any 'two copies of VTK installed' type conflicts. Also, be sure to unset any VTK paths you might have set in your configuration files (for example, ~/.bashrc)
download and install the latest version of cmake from
http://www.cmake.org/ download the source and any other parts of VTK you want from
http://public.kitware.com/ untar the source tarball
untar the data tarball. The data files are not necessary but might be useful. If you just want to get VTK and MayaVi installed you don't need to get it.
run ccmake . where you untarred the source
make sure you configure after each page of changes
choose your desired settings. Here, I've turned on all builds except VTK_WRAP_JAVA (note: VTK_USE_HYBRID is useful to have and the standard heart.mv example included in MayaVi will work only if this is turned on)
check all paths are correct for Python and Tcl (2.3 and 8.4 respectively). The paths I tested this with were PYTHON_INCLUDE_PATH=/usr/include/python2.3, PYTHON_LIBRARY=/usr/lib/python2.3/config/libpython2.3.a, TCL_INCLUDE_PATH=/usr/include, TCL_LIBRARY=/usr/lib/libtcl8.4.so, TK_INCLUDE_PATH=/usr/include and TK_LIBRARY=/usr/lib/libtk8.4.so
Make absolutely sure that the version of Tcl/Tk that Tkinter was built with (look for _tkinter.so and run ldd on it to find out) is the same as the one you choose in the above. If you don't you will get a segmentation fault when you run MayaVi.
Building with Tcl support is not absolutely essential if you only want to get MayaVi working. However, make sure that you set the right paths to the TCL_LIBRARY and TK_LIBRARY etc. as described earlier.
point VTK_DATA_ROOT to wherever you untarred the data tarball (if you downloaded it).
configure (c), generate (g) and exit ccmake
run cmake . in the source directory
run make in the source directory
get a cup of tea. This is the really long part. On my machine, this took around an hour and a half, though it can easily take longer
note that if you're using a later gcc (such as 3.3 as I am here) then *many* warnings will be thrown during the build. This is OK, as these are really just deprecation warnings
after the build has finished, this is usually the point where one would sudo make install; however I'm not going to - I would rather point the paths to the build directory in ~/ rather than install system-wide
manually fix the vtkLoadPythonTkWidgets.py file (more details in CommonInstallationProblems)
add the following into ~/.bashrc or equivalent (SETENV etc.):
export VTK_ROOT=/path/to/VTK export VTK_WRAPPING=$VTK_ROOT/Wrapping/Python export PYTHONPATH=$PYTHONPATH:$VTK_ROOT:$VTK_ROOT/bin:$VTK_WRAPPING export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$VTK_ROOT/bin export PATH=$PATH:$VTK_ROOT:$PYTHONPATH
(note some of these may be superfluous, but it doesn't hurt to be thorough)
If you want to install system-wide or want to look at other options you might want to read Wrapping/Python/README.txt in the VTK source directory
download the MayaVi source and untar
go into the MayaVi source folder, into the doc subdirectory and run ./test_vtk.py
if everything is OK here, great. MayaVi should now run. Try it out by going into the MayaVi source folder and running ./mayavi
install MayaVi sudo python setup.py install
I always like to make a copy of the mayavi file to ~/bin
MayaVi should now run from anywhere on the command line, and as an imported module. Test this with:
me@host:~> python >>> import mayavi >>> mayavi.mayavi() <mayavi.Main.MayaViTkGUI instance at 0x42a9492c>
a nice MayaVi instance appears; now we can script properly with MayaVi
MayaVi Wiki