ImportError using pyvista

Hi, I have an app ( that uses pyvista via the stpyvista component. It works fine locally, but when deployed with Streamlit Community Cloud it encounters the error
ImportError 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 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


seemed to get me farther with the new error ImportError: 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



[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/", line 534, in _run_script

    exec(code, module.__dict__)

  File "/mount/src/structura/pages/2_📊", line 109, in <module>


  File "/mount/src/structura/pages/2_📊", line 86, in run


  File "/home/adminuser/venv/lib/python3.11/site-packages/pyvista/plotting/utilities/", line 47, in start_xvfb


OSError: Please install Xvfb with:


$ 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 cannot open shared object file No such file or directory - Streamlit Docs.

Thank you for sharing your challenges and solutions, @BenGravell! :raised_hands:

Creating a distilled version of this info for our KB is also an excellent suggestion, that’s valuable guidance for others encountering similar PyVista deployment challenges in Community Cloud – We’re taking note! :+1:


@BenGravell, the next issue you will probably encounter is that each user will start a new xvfb process. This ends up rapidly consuming memory, though only one instance of xvfb is actually necessary to be running in the server. That’s just a limitation that comes from deploying in Community Cloud where we don’t have that level of control of the machine.

For reference, stpyvista’s demo app ( is setup in the Community Cloud to start xvfb only if it is not running yet:

@edsaac Thanks so much for the advice & the code! I see you ran into the same thing as the stypvista author - I should have just looked at your app :upside_down_face: At least I know I’m not crazy :sweat_smile:

wonder who that is :face_in_clouds:

Thanks BenGravell!
Was able to publish my app because of your post.
If you want to create a 3D model of Switzerland feel free to use it Swiss3D :partying_face:

1 Like