Sunday, September 10, 2017

Python-vtk module missing in virtual enviroment

installing Mayavi with pip – no module named vtk



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:
1. install vtk and python-vtk
sudo apt-get install vtk6
sudo apt-get install python-vtk
2. try
python -c "import vtk"
if failed again, go to step 3
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
4. try this again
python -c "import vtk"
5. if no import error, just do
python2 -m pip install mayavi

No comments:

Post a Comment