VTK9.2.2 Python Cylinder example will not run on Ubuntu from fresh conda (or pip) install

Hi there!

I am trying to get vtk to run and I am getting the following error on the Python Cylinder (“hello world”) example.

libGL error: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast
2022-12-05 22:21:59.998 (   0.034s) [        2CF0D740]vtkXOpenGLRenderWindow.:651    ERR| vtkXOpenGLRenderWindow (0x119e300): Cannot create GLX context.  Aborting.
[1]    13124 IOT instruction (core dumped)  python -m hello_world

To Reproduce

$ conda create -n vtk_env python=3.9 vtk
$ conda activate vtk_env
$ python -m hello_world # Where hello_world contains the copy/pasted Cylinder code

Are iris and swrast dependencies that are supposed to be installed with vtk? How can I ensure that these get installed on my students’ machine and they do not encounter this?

Many thanks!

Those modules are provided by the libgl1-mesa-dri package, so please verify it is installed:

dpkg -l libgl1-mesa-dri

What version of ubuntu are you using? And what version of the conda “mesalib” package?

Hi David,

Thank you for the response. I needed to check to see if this problem exists on Windows and Mac OSX too. Vtk installed on those platforms easily with only a pip install vtk.

I did an apt install of the libgl1-mesa-dri library and also did a conda install mesalib but the problem was not solved. Do they need to be installed in a particular way? I did not see this dependency listed on the install page. Can you tell me more about how to install this dependency?

Many thanks,

Connor

The VTK pypi package for pip and the VTK conda package are different things. The pypi package is released by Kitware, while the conda package is maintained by a different group: https://github.com/conda-forge/vtk-feedstock

I’ve installed VTK on linux via pip (no conda) without needing to install any dependencies. I don’t use conda, so I don’t know much about its VTK package.

Ah! Ok! Good to know. I tried installing with pip first, then went to conda thinking that it was the same or more comprehensive of an installation process.

That being the case, I started a fresh environment (Python 3.9) and installed vtk (9.2.2) with pip install vtk.

However, I am still getting the same error:

libGL error: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast
2022-12-12 07:41:34.443 (   0.032s) [        5FD7D740]vtkXOpenGLRenderWindow.:651    ERR| vtkXOpenGLRenderWindow (0x156de40): Cannot create GLX context.  Aborting.
[1]    9946 IOT instruction (core dumped)  python -m hello_world

Are these dependencies expected to be in the OS already? Is there documentation for these dependencies and their installation?

Also here is the output of dpkg ...

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                  Version                               Architecture Description
+++-=====================-=====================================-============-====================================================
ii  libgl1-mesa-dri:amd64 22.2.0-1pop0~1664294850~22.04~4e1b64f amd64        free implementation of the OpenGL API -- DRI modules

If you use the pip package, then make sure that your environment doesn’t have any conda-specific paths or environment variables (type env in your shell to check what vars are set).

Since you’re seeing dependency errors for libs and you’ve verified that those libs are installed on your system, I suspect that conda-installed libraries are somehow interfering with your system libraries. You can use ldd to see what’s linked, for example:

ldd lib/python3.9/site-packages/vtkmodules/libvtkRenderingOpenGL2-9.2.so

Problem is caused with an interaction with conda in Linux. Solution was to execute:

conda install -c conda-forge libstdcxx-ng

as per:

Now, everything works!