`ImportError: libGL.so.1` for `from ovito.io import import_file` in headless environment

Hi!

I’m trying to import ovito in a headless CI enviroment. Specifically, I import the function from ``ovito.io`` import import_file. However, that seems like it needs GUI libraries, since an OpenGL error is raised.

I’ve tried working around this using the approach in ovito.vis ( ovito.vis — OVITO Python Reference 3.15.5 documentation ), as follows:

import os; os.environ[‘OVITO_GUI_MODE’] = ‘0’; from ovito.io import import_file

which raises

Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python3.11/site-packages/ovito/init.py”, line 22, in
import ovito._extensions
File “/usr/local/lib/python3.11/site-packages/ovito/_extensions/init.py”, line 6, in
importlib.import_module(modinfo.name)
File “/usr/local/lib/python3.11/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/ovito/_extensions/anari.py”, line 2, in
import ovito._extensions.pyscript
File “/usr/local/lib/python3.11/site-packages/ovito/_extensions/pyscript.py”, line 2, in
import ovito.plugins.PyScript
File “/usr/local/lib/python3.11/site-packages/ovito/plugins/init.py”, line 40, in
from ovito.qt_compat import QtGui
File “/usr/local/lib/python3.11/site-packages/ovito/qt_compat.py”, line 29, in getattr
module = import_module(f’PySide6.{name}')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

I’ve tested this for python 3.11, 3.12, 3.13, and 3.14, and it is present in all versions. Any guidance on how to run ovito in a headless enviroment would be much appreciated!

Here is a docker oneliner for reproducing the issue:

docker run -t python:3.12 sh -c “pip install ovito && python3 -c “import os; os.environ[‘OVITO_GUI_MODE’] = ‘0’; from ovito.io import import_file””

Hi,

Yes, the OVITO Python module includes image rendering functions that require an OpenGL shared library—even if you are not actively using these rendering functions. The best way to avoid this error is to install the missing system library, libGL.so.1, in your system environment using your Linux distro’s package manager. Please follow the troubleshooting instructions for Linux found here:

1 Like

Thank you for the reply! I had missed that part of the manual.

I tried installing OpenGL per the instructions in the python 3:13 docker image, but since the image is quite minimal some extra steps seems to be required to actually get OpenGL installed. For example, the libgl1-mesa-glx is not available even though the image is debian-based.

Will report back here once I’ve figured out how to get OpenGL installed in such a minimal container.