2016-03-03 85 views
3

下載最新版本的VTK的(7.0.0)從vtk.org的tar.gz文件後,我做了一個build文件夾,運行ccmake,標誌設置爲Python3.5,設置標誌PYTHON_WRAPPING打開並運行make,然後進行make install。然後,我做了一個問題安裝VTK

>>> 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' 

任何想法,這可能是爲什麼發生?

+0

你有Python的3.5安裝?我猜測默認的Python版本是2.7,否則你必須設置比PYTHON_WRAPPING更多的變量。 –

+1

爲Python 3.5安裝VTK是一場完全的噩夢。它的每一部分都是你正確的,另一部分則向你拋出一些東西。我有完全相同的問題。讓我們知道您是否找到了解決方法。 – Pouria

回答

3

我張貼VTK的郵件列表和伯納德·吉魯的答覆是在同一個工作。下面是它(OS X埃爾卡皮坦):

  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 /本地VTK -> VTK-7.0.0
  3. 做一個符號鏈接在.bash_profile中添加

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

    (或者任何python3.5/site-packages的路徑; which python3.5都可以使用得到這個)

這對我有效。

+0

我不知道爲什麼VTK並不在他們的文檔包括此:-( – polarise