installing Mayavi with pip - no module named vtk

I'm on Debian but this should work for you as well

I was stuck with installing vtk into a virtualenv, after hours of search with no results I did the following and it worked.

  1. install python-vtk from repositories systemwide

  2. copy vtk folder from /usr/lib/pymodules/python2.7 to /PATH/TO/YOUR/VIRTUALENV/lib/python2.7/site-packages

In your case the system-wide python packages folder would probably be different but you can easily find it by firing up system python and entering the following:

import vtk,sys
print(sys.modules['vtk'])

After this trick mayavi was succesfully installed into my virtualenv using pip install mayavi and pip install envisage.

Edit: instead of copying it might better to just symlink the folder in step 2


Your pip is probably using a different python, kind of you have vtk installed using /usr/local/bin/python, while your pip binary uses /usr/bin/python.

Check it:

$ head -n1 $(which pip)

In order to get it solved, you can choose to use a virtualenv, or install pip using /usr/local/bin/python:

curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | /usr/local/bin/python

For more installation instructions, see http://www.pip-installer.org/en/latest/installing.html