vtk python wrapper problem with compilation

I am using 8.2_0.4 version of vtk

Hi David,
Thank you for a help,

I inserted block with hierarchy before call vtk_wrap_python3 and now I have again a long time of compilation with message

Scanning dependencies of target vtkGeodesicHierarchy
[ 10%] For vtkGeodesic - updating vtkGeodesicHierarchy.txt

Help me please to solve this problem!


this is link on my make file

also I your file vtkWrapHierarchy.cmake for include in my cmake file.

But I have a same effect - I can’t compile module

10:59:34 **** Build of configuration Default for project vtkGeodesic ****

Scanning dependencies of target vtkGeodesicHierarchy
[ 10%] For vtkGeodesic - updating vtkGeodesicHierarchy.txt

this commands hands up

/usr/local/Cellar/vtk/8.2.0_4/bin/vtkWrapHierarchy-8.2 @vtkGeodesicHierarchy…args -o /Users/idaymand/workspace/vtkGeodesic/Debug/vtkGeodesicHierarchy.txt vtkGeodesicHierarchy.data

file GeodesicHierarchy…args






this file is not exist

file vtkGeodesicHierarchy.data



I am right understand, that file
is output?


Hi David,
I researched my problem with stand up of vtkWrapHierarchy-8.2 by process of parsing headers, and I think, that I have a problem with description of head file.

Below is link on my header file, can you look please, may be something need add?



Hi Inna,

You are correct that there is a problem parsing the header, it is triggered by this code:


This is very strange, because it works fine if spaces are added:

"," << axes_x.GetY();

It’s a little mystery that I can investigate.

For wrapping with VTK 8.2, see the cmake code below. Note that I removed “MODULE” from the first add_library(). The only thing that should be built as a module is the python module, vtkGeodesicPython.so (or .pyd on Windows).

The PROPERTY POSITION_INDEPENDENT_CODE ON is needed in case you are doing a static build on a 64-bit linux (or mac) system and linking the static libraries to the python module (it enables the ‘-fPIC’ option of the compiler).

# Building vtkGeodesic
add_library(${LIB_NAME} vtkGeodesic.cpp)
target_link_libraries(${LIB_NAME} ${VTK_LIBRARIES})

# Wrapping vtkGeodesic
# All libs mentioned here must be listed in the find_package(VTK ...) 
set(${LIB_NAME}_LINK_DEPENDS vtkCommonCore vtkCommonDataModel)
set(${LIB_NAME}_WRAP_DEPENDS vtkCommonCore vtkCommonDataModel)

foreach(dep ${${LIB_NAME}_LINK_DEPENDS})

vtk_wrap_hierarchy(${LIB_NAME} ${CMAKE_CURRENT_BINARY_DIR} "${LIB_SRCS}")

vtk_wrap_python3(${LIB_NAME}Python ${LIB_NAME}Python_SRCS vtkGeodesic.cpp)

MESSAGE("vtkGeodesicPython_SRCS = ${vtkGeodesicPython_SRCS}")

add_library(${LIB_NAME}PythonD ${${LIB_NAME}Python_SRCS} vtkGeodesic.cpp)
set_property(TARGET ${LIB_NAME}PythonD


add_library(${LIB_NAME}Python MODULE ${LIB_NAME}PythonInit.cxx)

set(VTK_MODULES_USED vtkCommonDataModel vtkCommonCore)



target_link_libraries(${LIB_NAME}Python ${LIB_NAME}PythonD ${VTK_PYTHOND_LIBS})

set_target_properties(${LIB_NAME}Python PROPERTIES PREFIX "")
    set_target_properties(${LIB_NAME}Python PROPERTIES SUFFIX ".pyd")

Hi David,
thank you very mush for your help, I got a file vtkGeodesicPython.so.

But in Python

import vtkGeodesicPython

does not work, symbol not resolved before running.

I work with Python 3.6, may be problem in this?

I tried to find where I am connecting version of library Python 3.7 in my cmake file, but not found.

I saved this file in subfolder ./lib, this subfolder is registered in PYTHONPATH of project.

Help me please to understand what I do not right.


What symbol is not resolved? How is your VTK installed?

I am working on the Mac Sierra, in Eclipse with plugin PyDev, and using Python 3.6

I installed VTK with homebrew (homebrew install vtk).

I write
import vtkGeodesicPython

in python file, and I am getting information, that import not resolved. If I trace this line in debug, my Python is crashing.

Also need note, that I haven’t____init__.py I didn’t get it as result of compilation.

According to the homebrew page, their VTK package uses Python 3.7.5. So if you want to use homebrew’s VTK, you must use homebrew’s Python 3.7.

If your project requires Python 3.6, then you will have to build VTK with Python 3.6.

Hi David,

I researched a question with version, and I have following data

  1. With Python 3.6 is delivering vtk 8.1.2 for mac os sierra
  2. on the site download VTK there is only version 8.2.0 or 7.1.1 and lower.

What should I do? Download for c version of VTK 8.2.0 and use headers from it, but compile with library 8.1.2 from python?

Thanks a lot

You should use the Python 3.7 and VTK that comes with Homebrew, since you have already installed it.

Why are you using Python 3.6?

I am working in project that uses python 3.6 with vtk.

This is big project, and my job in it - is doing wrapper from c++ to python for realisation of critical important in terms of speed algorithm

I can not change version of python

May be, I can use headers from vtk 8.2 from homebrew, but by link include libraries from vtk 8.1.2?

Then your only choice is to download the VTK 8.2 source code and build VTK yourself.

May be, I can use headers from vtk 8.2 from homebrew, but by link include libraries from vtk 8.1.2?

No, you cannot use the VTK 8.2 headers with VTK 8.1.2 libraries.

One more question,

if I build VTK myself and build library with it, will i can use vtk 8.1.2 package for python 3.6 with my library? Or it must be use only VTK which i build myself?

Your library can only be used with the version of VTK that you use to build it.

It’s work with the Python that comes with Homebrew.

Thank you very much.

I will try check this on the windows

Hi David,

I tried to compile wrapper on the windows with visual studio compiler.

I did

  1. download VTK 8.2.0 from site vtk.org

  2. cmake -S source_path_of_VTK-8.2.0

  3. cmake --build build_path_of_VTK-8.2.0

  4. cmake --install build_path_of_VTK-8.2.0

  5. my VTK was installed and placed in folder C:/Program Files (x86)/VTK/ (with subfolders lib, bin, include, share)

  6. go in catalog with wrapper source
    https://bitbucket.org/InnaDaymand/vtkgeodesic/src/master/src/ (this is my source with make file)

  7. cmake -S path_of_source_vtkGeodesic

  8. get an error message
    CMake Error at C:/Program Files (x86)/VTK/lib/cmake/vtk-8.2/vtkModuleAPI.cmake:140 (message):
    Requested modules not available:

    Call Stack (most recent call first):
    C:/Program Files (x86)/VTK/lib/cmake/vtk-8.2/VTKConfig.cmake:143 (vtk_module_config)
    CMakeLists.txt:18 (FIND_PACKAGE)


What I did not right?

I have only