VTK 7.1.0 + Python 3.5.2 报错

VTK 7.1.0 + Python 3.5.2 make error

我在 Ubuntu 16.04 上使用 python 3.5.2 构建 VTK 7.1.0 时遇到错误。 找了好几遍都没弄明白怎么解决:/

我找到了一个关于它的对话,但他们没有找到解决方案。

前段时间,我使用相同的 python 3.5.2 构建了 VTK,它可以工作,但不知何故现在不工作了..

此错误的一小部分是:

In file included from /home/joaoponte/Downloads/VTK-git/vtk/Wrapping/Python/vtkPythonAppInit.cxx:29:0: /home/joaoponte/Downloads/VTK-git/vtk-build/Wrapping/Python/vtkpythonmodules.h: In function ‘void vtkpythonmodulesPythonLoadAllPythonModules()’:

/home/joaoponte/Downloads/VTK-git/vtk-build/Wrapping/Python/vtkpythonmodules.h:125:68: error: invalid conversion from ‘void ()()’ to ‘PyObject ()() {aka _object (*)()}’ [-fpermissive]

PyImport_AppendInittab(namevtkCommonCore, initvtkCommonCorePython); ^ In file included from /usr/include/python3.5m/Python.h:120:0, from /home/joaoponte/Downloads/VTK-git/vtk/Utilities/Python/vtkPython.h:80, from /home/joaoponte/Downloads/VTK-git/vtk/Wrapping/Python/vtkPythonAppInit.cxx:18: /usr/include/python3.5m/import.h:109:17: note: initializing argument 2 of ‘int PyImport_AppendInittab(const char*, PyObject* (*)())’

它对 vtkpythonmodules.h 文件中列出的所有模块重复。

在 vtkpythonmodules.h 我发现了这个(和其他):

extern void initvtkCommonCorePython();

还有这个:

static char namevtkCommonCore[] = "vtkCommonCorePython";
PyImport_AppendInittab(namevtkCommonCore, initvtkCommonCorePython);

在 Python.h 中,我发现了这个:

PyAPI_FUNC(int) PyImport_AppendInittab(
    const char *name,           /* ASCII encoded string */
    PyObject* (*initfunc)(void) 
    );

我正在使用从 git 下载的最新 VTK 版本和从 Ubuntu 16.04 下载的默认 python3,我使用 ccmake 进行配置。

python 可执行文件,include_dir 和库正在使用 python3.5m,但我也尝试了 python3.5,但也失败了:(

有没有人知道如何解决这个问题? 是 python3 还是我系统中的其他任何配置错误?

编辑:我发现在 python 2.7 的 import.h 文件中,PyImport_AppendInittab 似乎是 "right" (?) 那些......

PyAPI_FUNC(int) PyImport_AppendInittab(const char *name, void (*initfunc (void));

这是配置过程中的 ccmake 错误吗? 我选择 python3.5,但是 vtkpythonmodules.h 是使用 extern void.

创建的

我不太熟悉在 Ubuntu 上安装 VTK,但我们刚刚使用 conda 成功安装了 VTK。你可能会更幸运: conda install -c conda-forge vtk=7.1.0