安装 VTK 的问题

Problems installing VTK

从 vtk.org 下载最新版本的 VTK (7.0.0) 作为 tar.gz 文件后,我创建了一个构建文件夹 运行 ccmake,将标志设置为 Python3.5,将标志 PYTHON_WRAPPING 设置为 on,然后 运行 make 然后进行 make install。然后我做了一个

>>> import vtk

我收到以下错误:

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'

知道为什么会这样吗?

我在 VTK 的邮件列表上发布了同样的内容,Bernard Giroux 的回复有效。这是它的样子 (OS X El Capitan):

  1. 运行 cmake 具有以下选项:

    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. 在 /usr/local VTK -> VTK-7.0.0
  3. 中创建符号链接
  4. 在.bash_profile中添加

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

    (或 python3.5/site-packages 的任何路径;which python3.5 可用于获取此信息)

这对我有用。