I want to use Mayavi.
Situation
- I use a MacBook Air, with OSX 10.7.3.
- I use Python 2.7.2
- I have
virtualenvinstalled. But I have not used it for this installation.
I've manually installed all it's dependencies, including VTK.
For VTK, I followed its installation guide and installed the python wrapper.
Now if I open a new terminal window and open python, I can import vtk without any error.
Problem
I try to install Mayavi with the following command:
pip install mayavi But the following error occurs:
Downloading/unpacking mayavi Running setup.py egg_info for package mayavi build_src building extension "tvtk.array_ext" sources building data_files sources build_src: building npy-pkg config files no previously-included directories found matching 'artwork' no previously-included directories found matching 'docs/pdf' Requirement already satisfied (use --upgrade to upgrade): apptools in /Library/Python/2.7/site-packages (from mayavi) Requirement already satisfied (use --upgrade to upgrade): traits in /Library/Python/2.7/site-packages (from mayavi) Requirement already satisfied (use --upgrade to upgrade): traitsui in /Library/Python/2.7/site-packages (from mayavi) Requirement already satisfied (use --upgrade to upgrade): configobj in /Library/Python/2.7/site-packages (from apptools->mayavi) Requirement already satisfied (use --upgrade to upgrade): pyface in /Library/Python/2.7/site-packages (from traitsui->mayavi) Installing collected packages: mayavi Running setup.py install for mayavi Traceback (most recent call last): File "<string>", line 1, in <module> File "/Users/Yasser/build/mayavi/setup.py", line 498, in <module> **config File "/Library/Python/2.7/site-packages/", line 186, in setup return old_setup(**new_attr) File "/System/Library/Frameworks/", line 152, in setup dist.run_commands() File "/System/Library/Frameworks/", line 953, in run_commands self.run_command(cmd) File "/System/Library/Frameworks/", line 972, in run_command cmd_obj.run() File "/Library/Python/2.7/site-packages/", line 57, in run r = self.setuptools_run() File "/Library/Python/2.7/site-packages/", line 31, in setuptools_run return old_install_mod._install.run(self) File "/System/Library/Frameworks/", line 573, in run self.run_command('build') File "/System/Library/Frameworks/", line 326, in run_command self.distribution.run_command(command) File "/System/Library/Frameworks/", line 972, in run_command cmd_obj.run() File "/Users/Yasser/build/mayavi/setup.py", line 303, in run build_tvtk_classes_zip() File "/Users/Yasser/build/mayavi/setup.py", line 290, in build_tvtk_classes_zip gen_tvtk_classes_zip() File "tvtk/setup.py", line 46, in gen_tvtk_classes_zip from code_gen import TVTKGenerator File "tvtk/code_gen.py", line 10, in <module> import vtk ImportError: No module named vtk Complete output from command /usr/bin/python -c "import setuptools;__file__='/Users/Yasser/build/mayavi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/53/_trhc_0x0fb6kvx6bw_wrk500000gn/T/pip-Z4hpsW-record/install-record.txt: running install running build Traceback (most recent call last): File "<string>", line 1, in <module> File "/Users/Yasser/build/mayavi/setup.py", line 498, in <module> **config File "/Library/Python/2.7/site-packages/", line 186, in setup return old_setup(**new_attr) File "/System/Library/Frameworks/", line 152, in setup dist.run_commands() File "/System/Library/Frameworks/", line 953, in run_commands self.run_command(cmd) File "/System/Library/Frameworks/", line 972, in run_command cmd_obj.run() File "/Library/Python/2.7/site-packages/", line 57, in run r = self.setuptools_run() File "/Library/Python/2.7/site-packages/", line 31, in setuptools_run return old_install_mod._install.run(self) File "/System/Library/Frameworks/", line 573, in run self.run_command('build') File "/System/Library/Frameworks/", line 326, in run_command self.distribution.run_command(command) File "/System/Library/Frameworks/", line 972, in run_command cmd_obj.run() File "/Users/Yasser/build/mayavi/setup.py", line 303, in run build_tvtk_classes_zip() File "/Users/Yasser/build/mayavi/setup.py", line 290, in build_tvtk_classes_zip gen_tvtk_classes_zip() File "tvtk/setup.py", line 46, in gen_tvtk_classes_zip from code_gen import TVTKGenerator File "tvtk/code_gen.py", line 10, in <module> import vtk ImportError: No module named vtk ---------------------------------------- Command /usr/bin/python -c "import setuptools;__file__='/Users/Yasser/build/mayavi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/53/_trhc_0x0fb6kvx6bw_wrk500000gn/T/pip-Z4hpsW-record/install-record.txt failed with error code 1 in /Users/Yasser/build/mayavi Storing complete log in /Users/Yasser/Library/Logs/pip.log Traceback (most recent call last): File "/usr/local/bin/pip", line 8, in <module> load_entry_point('pip==1.1', 'console_scripts', 'pip')() File "/Library/Python/2.7/site-packages/", line 116, in main return command.main(args[1:], options) File "/Library/Python/2.7/site-packages/", line 141, in main log_fp = open_logfile(log_fn, 'w') File "/Library/Python/2.7/site-packages/", line 168, in open_logfile log_fp = open(filename, mode) IOError: [Errno 13] Permission denied: '/Users/Yasser/Library/Logs/pip.log' I think the problem is with vtk.
Can anyone help me?
Other Details
Running sudo pip install mayavi does not solve the problem.
I thought this might help
› which python /usr/local/bin/python › python Python 2.7.2 (default, Feb 17 2012, 13:57:55) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import vtk >>> vtk <module 'vtk' from '/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/ >>> My PYTHONPATH is empty.
7 Answers
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.
install python-vtk from repositories systemwide
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
1Your 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 | /usr/local/bin/python For more installation instructions, see
I had the same problem and the first answer didn't help me because pip was in the right directory, but it turned out I didn't have vtk installed - running sudo apt-get install python-vtk fixed the issue and I was able to successfully run pip install mayavi after that.
1I had the same problem when installing mayavi with python installed in pyenv, and I solved this problem by copy directory to /home/myname/.pyenv/versions/2.7.12/lib/python2.7/site-packages, below is my method:
install
vtkandpython-vtksudo apt-get install vtk6 sudo apt-get install python-vtktry
python -c "import vtk", if failed again, go to step 3the import error may caused by the loss of vtk package folder in your current python, so we should find the vtk folder and copy to your current python(most possible the python in pyenv shims directory)'s directory .
the path of the vtk folder in my ubuntu is
/usr/lib/python2.7/dist-packages/vtkjust copy the
vtkfolder to your current python's/site-packages, e.g.cp -r /usr/lib/python2.7/dist-packages/vtk /home/myname/pyenv/versions/2.7.12/lib/python2.7/site-packagestry
python -c "import vtk"again.if no import error, just do
pip install mayavi
I insisted in sudo install for several times, finally got solved, don't know how to explain.
sudo python2 -m pip install mayavi sudo python3 -m pip install mayavi UPDATE
I can't install via pip for laptop. Then I install the latest mayavi by
git clone cd mayavi pip install -r requirements.txt pip install PyQt5 # replace this with any supported toolkit python setup.py install # or develop after installation. Test with
mayavi2 Then report say couldn't find module PyQt5.Qtsvg, so
sudo apt install python3-pyqt5.qtsvg Now it works.
I encountered the same problem on Windows10. It turns out that numpy should be installed before mayavi using pip.
I installed vtk using Homebrew:
$ brew install vtk hope this helps.
1