ImportError: libGL.so.1: cannot open shared object file: No such file or directory: import cv2:native_module = importlib.import_module("cv2")

I am deploying streamlit app on streamlit cloud. The app uses yolov4 custom object detection model. I can not show the repo due to confidentiality issue. Can anyone help me solve the below issue


directory structure
image
requirements
image

Remove opencv-python from the req file, you only need the opencv-python-headless package.

1 Like

Thank you very much !

I encounter another problem in this application. I opened it today and it asked for reboot, I did the same but I am getting below error. I tried re-deployment as well but it is giving same error. I have not made any changes in my file.

I included opencv-python-headless, got another error, can you help me with it?

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

Hi @armM00 You can create a packages.txt file and include this in it

freeglut3-dev
libgtk2.0-dev

try reboot the website, it works for me

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