Hi, I have an app (https://structura.streamlit.app/) that uses pyvista
via the stpyvista
component. It works fine locally, but when deployed with Streamlit Community Cloud it encounters the error
ImportError libGL.so.1 cannot open shared object file No such file or directory
. I already looked through all of the other forum threads that mention this issue, as well as the official guidance at ImportError libGL.so.1 cannot open shared object file No such file or directory - Streamlit Docs. Most of these are dealing with opencv, which I am not using; my issue stems from pyvista
, which uses vtk
which also uses libgl
under the hood.
The standard fixes of adding libgl1
to packages.txt
and using opencv-python-headless
in requirements.txt
did not work for me.
I saw the same issue can be encountered in Dash apps: dash-vtk · PyPI
Changing the packages.txt to
libgl1-mesa-glx
libglib2.0-0
seemed to get me farther with the new error ImportError: libXrender.so.1: cannot open shared object file: No such file or directory
.
This led me to try adding libxrender1
to the packages.txt
.
Restarting the deployed app in this configuration led to the server crashing with error
This system does not appear to be running an xserver.
PyVista will likely segfault when rendering.
Try starting a virtual frame buffer with xvfb, or using
``pyvista.start_xvfb()``
warnings.warn(
[15:22:25] ❗️ Streamlit server consistently failed status checks
[15:22:25] ❗️ Please fix the errors, push an update to the git repo, or reboot the app.
Trying the suggestion to add pyvista.start_xvfb()
to the python code (in the streamlit app) & restarting allowed the app to run, then failed with the new error
2023-11-11 15:29:33.660 Uncaught app exception
Traceback (most recent call last):
File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
exec(code, module.__dict__)
File "/mount/src/structura/pages/2_📊_Results.py", line 109, in <module>
run()
File "/mount/src/structura/pages/2_📊_Results.py", line 86, in run
pyvista.start_xvfb()
File "/home/adminuser/venv/lib/python3.11/site-packages/pyvista/plotting/utilities/xvfb.py", line 47, in start_xvfb
raise OSError(XVFB_INSTALL_NOTES)
OSError: Please install Xvfb with:
Debian
$ sudo apt install libgl1-mesa-glx xvfb
CentOS / RHL
$ sudo yum install libgl1-mesa-glx xvfb
Adding xvfb
to packages.txt
and restarting the app once again at long long last finally allowed the app to work properly.
Leaving this here for posterity to save someone else the hours I spent chasing down these deployment issues. It would be great if a cleaned up / distilled version of this information could be posted in the Knowledge Base just like ImportError libGL.so.1 cannot open shared object file No such file or directory - Streamlit Docs.