ImportError: libvtksys-9.0.so.1 and ModuleNotFoundError: No module named '_vtkmodules_static'
Hi,
The environment are Ubuntu 19.10 + git version of vtk. I compile and install it successfully with the following steps for python 3.8.2:
eval "$(pyenv init -)"
pyenv shell 3.8.2
if [ $? -ne 0 ]; then
echo 'pyenv failed to work.'
exit
fi
PYTHON_EXECUTABLE=$(pyenv which python)
CMAKE_INSTALL_PREFIX=$( pyenv which python | xargs realpath | sed -r 's,/bin/python[0-9.]*$,,')
PYTHON_INCLUDE_DIR=$( find $CMAKE_INSTALL_PREFIX/include/python* -maxdepth 0 -type d -regextype posix-extended -regex ".*/python[0-9.]*$" )
PYTHON_LIBRARY=$( find $CMAKE_INSTALL_PREFIX/lib/libpython* -maxdepth 0 -type f -regextype posix-extended -regex ".*/libpython[0-9.]*.so$" )
echo "Install vtk with the following settings:"
echo "PYTHON_EXECUTABLE=$PYTHON_EXECUTABLE"
echo "CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX"
echo "CMAKE_INSTALL_RPATH=$CMAKE_INSTALL_PREFIX"
echo "PYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR"
echo "PYTHON_LIBRARY=$PYTHON_LIBRARY"
rm -fr build
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX \
-DCMAKE_INSTALL_RPATH=$CMAKE_INSTALL_PREFIX \
-DVTK_Group_Qt=ON \
-DVTK_QT_VERSION=5 \
-DVTK_Group_Imaging=ON \
-DVTK_Group_Views=ON \
-DModule_vtkRenderingFreeTypeFontConfig=ON \
-DVTK_WRAP_PYTHON=ON \
-DVTK_PYTHON_VERSION=3 \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
-DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
-DPYTHON_LIBRARY=$PYTHON_LIBRARY \
-DBUILD_TESTING=OFF \
-DVTK_USE_SYSTEM_LIBRARIES=ON \
-DVTK_USE_SYSTEM_LIBPROJ4=OFF \
-DVTK_USE_SYSTEM_GL2PS=OFF \
-DVTK_USE_SYSTEM_LIBHARU=OFF \
-DVTK_USE_SYSTEM_PUGIXML=OFF \
-DCMAKE_BUILD_TYPE=Release \
..
make -j24
make install
But I failed to import it:
werner@ubuntu-01:~$ python
Python 3.8.2 (default, Apr 27 2020, 15:38:15)
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
Traceback (most recent call last):
File "/home/werner/.pyenv/versions/3.8.2/lib/python3.8/site-packages/vtkmodules/__init__.py", line 13, in <module>
from . import vtkCommonCore
ImportError: libvtksys-9.0.so.1: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/werner/.pyenv/versions/3.8.2/lib/python3.8/site-packages/vtk.py", line 30, in <module>
all_m = importlib.import_module('vtkmodules.all')
File "/home/werner/.pyenv/versions/3.8.2/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/werner/.pyenv/versions/3.8.2/lib/python3.8/site-packages/vtkmodules/__init__.py", line 15, in <module>
import _vtkmodules_static
ModuleNotFoundError: No module named '_vtkmodules_static'
>>>
If complains the following:
ImportError: libvtksys-9.0.so.1: cannot open shared object file: No such file or directory
But the file really exists there:
werner@ubuntu-01:~/.pyenv/versions/3.8.2/lib$ realpath libvtksys-9.0.so.1
/home/werner/.pyenv/versions/3.8.2/lib/libvtksys-9.0.so.9.0.0
Any hints for this problem?
Regards