Ranveer
Ranveer

Reputation: 6863

Problems installing VTK

After downloading the latest version of VTK (7.0.0) as a tar.gz file from vtk.org, I made a build folder, ran ccmake, set the flag to Python3.5, set the flag PYTHON_WRAPPING to on and ran make followed by make install. Then I did a

>>> import vtk

I got the following error:

In [1]: import vtk
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/vtk/vtkCommonCore.py in <module>()
      4     # use relative import for installed modules
----> 5     from .vtkCommonCorePython import *
      6 except ImportError:

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/vtk/vtkCommonCorePython.so, 2): Library not loaded: libvtkCommonCorePython35D-7.0.1.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/vtk/vtkCommonCorePython.so
  Reason: image not found

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-1-b7e11aadda62> in <module>()
----> 1 import vtk

/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/vtk/__init__.py in <module>()
     39
     40 # --------------------------------------
---> 41 from .vtkCommonCore import *
     42 from .vtkCommonMath import *
     43 from .vtkCommonMisc import *

/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/vtk/vtkCommonCore.py in <module>()
      7     # during build and testing, the modules will be elsewhere,
      8     # e.g. in lib directory or Release/Debug config directories
----> 9     from vtkCommonCorePython import *

ImportError: No module named 'vtkCommonCorePython'

Any idea why this could be happening?

Upvotes: 3

Views: 3334

Answers (1)

Ranveer
Ranveer

Reputation: 6863

I posted the same on VTK's mailing list and Bernard Giroux's reply worked. Here's what it was (OS X El Capitan):

  1. Run cmake with the following options:

    cmake -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr/local/VTK-7.0.0 \
    -DVTK_WRAP_PYTHON=ON \
    -DVTK_PYTHON_VERSION=3 \
    -DCMAKE_MACOSX_RPATH=ON \
    -DCMAKE_INSTALL_NAME_DIR=/usr/local/VTK-7.0.0/lib ..
    
  2. Make a symlink in /usr/local VTK -> VTK-7.0.0
  3. In .bash_profile add

    export VTKPATH=/usr/local/VTK
    export PYTHONPATH=$VTKPATH/lib/python3.5/site-packages 
    

    (or whatever the path to python3.5/site-packages is; which python3.5 can be used to get this)

This worked for me.

Upvotes: 3

Related Questions