使用 Python 包装器编译 VTK



我正在尝试使用python包装器构建VTK库。我想开发一个python程序,以VTK格式对一些CFD结果进行后处理。

我正在本地文件夹中编译源代码。

不幸的是,我

面临几个问题:首先在编译过程中,我收到以下错误消息:

CMake Error at Common/Core/cmake_install.cmake:47 (file):
file INSTALL cannot find
"/home/riccardo/Software/VTK/build/lib/libvtkCommonCore-8.0.so.1".

我试图按照此处的建议禁用共享库选项 VTK 安装错误找不到 libvtkCommonCore-6.3.so.1在 CMAKE 配置中

cmake ..
  -DCMAKE_INSTALL_PREFIX=/home/riccardo/Software/VTK/build 
  -DBUILD_SHARED_LIBS:BOOL=OFF 
  -DCMAKE_BUILD_TYPE=Release 
  -DVTK_USE_SYSTEM_ZLIB:BOOL=ON

在这种情况下,编译运行顺利,但是当我尝试在python中导入vtk时,出现此错误:

from .vtkCommonCore import *
 42 from .vtkCommonMath import *
 43 from .vtkCommonMisc import *
 ~/Software/VTK/build/Wrapping/Python/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'   

我真的不知道如何解决它。任何帮助将非常受欢迎。

提前非常感谢!!

你有没有试过告诉CMake你想要包装的python版本?

也就是说,添加:

-D VTK_WRAP_PYTHON:BOOL=ON 
-D VTK_PYTHON_VERSION:STRING=3.5 # or your python version
-D PYTHON_EXECUTABLE:PATH=usrbinpython3 # or wherever your python exec is

在 CMake 配置中,看看会发生什么。

最新更新