libvtkRenderingTk-9.2.so : No such file or directory

Dear VTK developers,

I am encountering an issue with the libvtkRenderingTk-9.2.so library file when using VTK with Python. Specifically, I am receiving the following error message:

libvtkRenderingTk-9.2.so: cannot open shared object file: No such file or directory

I have followed the installation instructions provided in the VTK documentation. However, I am still encountering this error.

I would appreciate any assistance or guidance you can provide in resolving this issue. Please let me know if you require any additional information from me.

Thank you for your time and attention.

Sincerely

That library isn’t included in any of the VTK binary packages. VTK’s RenderingTk module is only available if it’s configured when VTK is built from source code.

I don’t understand; I am on ubuntu 20.04 and trying to build a GUI with Python 3.8.10, VTK 9.0.1, and Tkinter. Using VTK and Tkinter separately works well, but I struggle to combine them.

I have tried it with a vtkTkRenderWindowInteractor and a vtkTkRenderWidget so far, but I always obtain the error:

_tkinter.TclError: couldn’t load file “libvtkRenderingTk-9.0.so”: libvtkRenderingTk-9.0.so: cannot open shared object file: No such file or directory

That library, libvtkRenderingTk-9.2.so, is not included with the VTK binary packages. How did you install VTK 9.0.1? Was it pip, conda, or a .deb with apt-get? Or did you build VTK 9.0.1 from source code?

I tried installing VTK 9.0.1 with pip, and apt-get, but none of these methods seemed to include the libvtkRenderingTk-9.2.so library. Then, I tried to compile VTK 9.0.1 from source code, but I couldn’t resolve the issue of the missing library.

The pip package definitely doesn’t include libvtkRenderingTk-9.2.so, and I don’t think the deb does either.

For building from source, Tk must be enabled with VTK_USE_TK=ON. I recommend these options for VTK 9.0.1, it that’s the version of VTK that you need:

cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++-9 -DCMAKE_C_COMPILER=/usr/bin/gcc-9 \
 -DBUILD_SHARED_LIBS=ON -DVTK_BUILD_TESTING=OFF -DVTK_PYTHON_VERSION=3 \
 -DCMAKE_BUILD_TYPE=Release -DVTK_WRAP_PYTHON=ON -DVTK_USE_TK=ON \
 ../VTK-9.0.1

It will also be necessary to use apt-get to install the tk-dev and tcl-dev packages before running cmake.