I want to use Mayavi.
virtualenv
installed.
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 https://github.com/enthought/mayavi.git
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.
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
I 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 vtk
and python-vtk
sudo apt-get install vtk6
sudo apt-get install python-vtk
try python -c "import vtk"
, if failed again, go to step 3
the 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/vtk
just copy the vtk
folder 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-packages
try python -c "import vtk"
again.
if no import error, just do
pip install mayavi
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.
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
I installed vtk using Homebrew:
$ brew install vtk
hope this helps.