[Streamlit sharing] Importerror: libgl.so.1: cannot open shared object file: no such file or directory opencv error

Hello guys i am getting the same errors as above but i have deployed the app through heroku, it is successfully deployed but getting an error same as above please help.

this is the content of my requirement.txt file:
streamlit==0.84.1
opencv-python-headless
numpy==1.19.5
Pillow==8.2.0
mediapipe==0.8.6
face-recognition==1.3.0

link to deployed app:
https://facerecog-streamlit.herokuapp.com/

Thanks a lot @snehankekre you really save my day, I’ve been stuck on this issue for 6 hours :dizzy_face:
and it was missing (libgl1-mesa-glx) in the packages.txt

Hi,
I’ve tried my best but I’m not able to resolve the error.
please help

My requirement.txt file contains the following
av==9.2.0
keras==2.9.0
mediapipe==0.8.10.1
numpy==1.23.0
opencv-python-headless==4.6.0.66
streamlit==1.10.0
streamlit_webrtc==0.42.0

Please share a link to your public github repo.

here

Where do you run your streamlit app? Locally? Streamlit Cloud? Which Python version?

Besides, i would use:

opencv-python-headless==4.5.4.60

Its running smoothly on my localhost, but giving me error when trying to deploy it on heroku or streamlit.
On my local machine I’ve Python 3.10.5 installed.

Can you please check?

You haven’t tried my suggestion yet.

I tried it didn’t work, you can see the changes in my repo

What is the error message (no screenshots please)?
Where did you try? Heroku? Streamlit Cloud?

I tried on both getting the same error.

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

File “/app/.heroku/python/lib/python3.10/site-packages/streamlit/scriptrunner/script_runner.py”, line 554, in _run_script
exec(code, module.dict)File “music.py”, line 4, in
import cv2

What’s the possible solution for this?

1 Like

Thank you snehan, it did worked :metal:

1 Like

Hi @snehankekre
I’ve deployed an app on streamlit and everytime I run the app it crashes.
url@ https://mdammar70-mood-based-music-recommender-music-a0opxo.streamlitapp.com/

so first it takes Song Language & Singer name as input then it captures facial expressions to detect the mood of the user, but the app crashes in midway.

can you please check.

Can you please reply?

I got the same problem with open cv. I can run it locally but it doesn’t work online.

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)File "/app/web_app_streamlit/pages/02_Gender_and_Age_detection.py", line 4, in <module>
    import cv2

Here is my app: https://nguyendangson-web-app-streamlit-about-jksqna.streamlit.app/Gender_and_Age_detection
Please help me to solve it. Thank you.

Hi all, I have read the all methods above and tried different variations of requirements and packages.

I am currently receiving this error.
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

My requirement.txt file is as such
numpy
opencv-python-headless
mediapipe
streamlit
streamlit_webrtc

and my packages.txt file is as such:
freeglut3-dev
libgtk2.0-dev
libgl1
libgl1-mesa-glx
tesseract-ocr
libtesseract-dev
libtesseract4
tesseract-ocr-all

Below is my github repo link:

Can I ask for some help?

@khammingfatt
You probably don’t need most of the stuff in your packages.txt file.
Here are some hints: