installing Mayavi with pip - no module named vtk

前端 未结 6 2010
耶瑟儿~
耶瑟儿~ 2020-12-24 11:48

I want to use Mayavi.

Situation

  • I use a MacBook Air, with OSX 10.7.3.
  • I use Python 2.7.2
  • I have virtualenv installed.
6条回答
  •  天涯浪人
    2020-12-24 12:29

    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 python -c "import vtk" again.

    5. if no import error, just do

      pip install mayavi
      

提交回复
热议问题