VTK 8.1.2 with VTK_WRAP_PYTHON: Installation problem on macOS

Hi everyone,

I try to install VTK 8.1.2 with python support on macOS 10.14.3 (Mohaje).
I use python 3.6.8 from anaconda, Qt 5.12.1, and the default clang obtained by XCode.
I configure vtk like this:

cmake .. \
-DVTK_WRAP_PYTHON=ON \
-DVTK_Group_Imaging=ON \
-DVTK_Group_Imaging=ON \
-DVTK_Group_Qt=ON \
-DVTK_Group_Rendering=ON \
-DVTK_Group_StandAlone=ON \
-DVTK_Group_Views=ON \
-DVTK_Group_Web=ON \
-DModule_vtkDICOM=ON \
-DUSE_GDCM=ON \
-DCMAKE_INSTALL_PREFIX=/a/path/to/my/install \
-DCMAKE_MACOSX_RPATH=ON \
DCMAKE_INSTALL_RPATH=/a/path/to/my/install/lib

The configuration and building parts work perfectly.
I succeed to launch vtkpython directly from the building folder but once installed, I obtain this error:

dyld: Library not loaded: @rpath/libpython3.6m.dylib
Referenced from: //a/path/to/my/install/bin/./vtkpython
Reason: image not found
Abort trap: 6

Does anyone what I did wrong?

Thank you,

Romain

Edit:
I figure a way to use VTK in python (using the python executable provided by Anaconda not vtkpython):
I added the following environment variables on my .bashrc file:

export DYLD_FALLBACK_LIBRARY_PATH=/vtk_install_path/lib
export PYTHONPATH=/vtk_install_path/lib/python3.6/site-packages

I have build VTK with Qt support so I need to add this variable to:

export DYLD_FRAMEWORK_PATH=/vtk_install_path/Qt/5.12.1/clang_64/lib

It works fine but not with the vtkpython executable. When I use otool on vtkpython I have the following dependencies:

vtkpython:
@rpath/libvtkWrappingPython36Core-8.1.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libutil.dylib (compatibility version 1.0.0, current version 1.0.0)
@rpath/libpython3.6m.dylib (compatibility version 3.6.0, current version 3.6.0)
@rpath/libvtkCommonCore-8.1.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@rpath/libvtksys-8.1.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

I have two questions on this:

  1. Why the @rpath for vtk libraries is not something like that: @rapth/…/lib/libvtk*.dylib?
  2. Why is there a @rpath for the libpython3.6m.dylib and not the installed path?

Thank you again :slight_smile:

Edit 2:
I try to build with default Python (python2.7) with the same options. When I use otool on vtkpython, I obtain this time:

vtkpython:
@rpath/libvtkWrappingPython27Core-8.1.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libutil.dylib (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
@rpath/libvtkCommonCore-8.1.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@rpath/libvtksys-8.1.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

The python library is an absolute path and vtkpython work fine.
Unfortunately I need to use Python 3 because of other dependencies for my projects.