Streamlit Cloud apt deps failing + OpenCV import errors (libGL / libgthread)

1. Public app link:
https://face-stimuli-generator.streamlit.app

2. Public GitHub repo link (with requirements):
https://github.com/omertzuk/vmmr_face_stimuli_maker

3. Full error message:

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

and later after adjusting apt packages:

ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory

Apt dependency installation failure from logs (relevant excerpt)

The following packages have unmet dependencies:
libglib2.0-0 : Depends: libffi7 (>= 3.3~20180313) but it is not installable
Depends: libpcre3 but it is not installable
Recommends: libglib2.0-data but it is not going to be installed
Recommends: shared-mime-info but it is not going to be installed
Recommends: xdg-user-dirs but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
E: The following information from --solver 3.0 may provide additional context:
Unable to satisfy dependencies. Reached two conflicting decisions:

  1. libglib2.0-0:amd64=2.66.8-1+deb11u8 is selected for install
  2. libglib2.0-0:amd64 Depends libffi7 (>= 3.3~20180313)
    but none of the choices are installable:
    [no choices]

4. Streamlit + Python versions:

  • Streamlit 1.58.0

  • Python 3.14.5 (from Cloud logs)

Extra context:

  • App entrypoint: stimulus_generation\gui\app.py

  • Using opencv-python-headless in requirements.

  • Attempted packages.txt with libgl1 and libgles2, but adding libglib2.0-0 fails due to missing libffi7/libpcre3 on the base image.

Welcome to the Streamlit community and thanks for the detailed info! :tada: You’re running into a common deployment issue: ImportError for libGL.so.1 and libgthread-2.0.so.0, and apt dependency failures for libglib2.0-0 due to missing libffi7 and libpcre3. This is because Streamlit Community Cloud uses Debian Bullseye, which doesn’t provide libffi7 or libpcre3 anymore, so installing libglib2.0-0 fails and breaks your dependency chain. This is a known limitation of the current Community Cloud base image and not something you can fix from your end by tweaking packages.txt alone.

The best-practice workaround is to only include libgl1 (and possibly libgles2) in your packages.txt, and avoid adding libglib2.0-0, as it will always fail due to the missing dependencies in the current environment. For OpenCV, ensure you use opencv-python-headless in requirements.txt and only libgl1 in packages.txt. If another library (like imageai or mediapipe) is forcing opencv-python (non-headless) or libglib2.0-0, you may need to pin versions or remove those dependencies if possible. For more, see the official Streamlit docs on apt dependencies and community troubleshooting.

If you share a minimal reproducible example or your requirements.txt and packages.txt, the community can help debug further! And if you find a dependency that absolutely requires libglib2.0-0, you may need to consider self-hosting or Docker deployment, as Community Cloud’s base image can’t satisfy that dependency right now.

Sources: