Trying to deploy an app which uses cv2. Getting different errors

req-s.txt containis:

opencv-python-headless

Error:

ImportError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).

Traceback:

File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 552, in _run_script
exec(code, module.dict)File “/app/all-in-one/main.py”, line 11, in
from elements.selfie_AI.selfie import PhotoAPPFile “/app/all-in-one/elements/selfie_AI/selfie.py”, line 2, in
import cv2File “/home/appuser/venv/lib/python3.9/site-packages/cv2/init.py”, line 181, in
bootstrap()File “/home/appuser/venv/lib/python3.9/site-packages/cv2/init.py”, line 153, in bootstrap
native_module = importlib.import_module(“cv2”)File “/usr/local/lib/python3.9/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)

The logs:

2023-06-18 01:55:49.999 Uncaught app exception

Traceback (most recent call last):

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script

    exec(code, module.__dict__)

  File "/app/all-in-one/main.py", line 11, in <module>

    from elements.selfie_AI.selfie import PhotoAPP

  File "/app/all-in-one/elements/selfie_AI/selfie.py", line 2, in <module>

    import cv2

  File "/home/appuser/venv/lib/python3.9/site-packages/cv2/__init__.py", line 181, in <module>

    bootstrap()

  File "/home/appuser/venv/lib/python3.9/site-packages/cv2/__init__.py", line 153, in bootstrap

    native_module = importlib.import_module("cv2")

  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, 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
1 Like

Hi @armM00,

Thanks for posting!

Do you have a packages.txt file that contains system-level dependencies?

If not, create a file named packages.txt in your root directory (same directory as your requirements.txt file. Add the following to the packages file:

libgl1

Here’s a more detailed guide in our knowledge base.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.