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

importerror: libgl.so.1: cannot open shared object file: no such file or directory

I’m getting this error while installing opencv python on streamlit share how to resolve it.

1 Like

Hi @harish_natarajan,

I will need a bit more information to understand whats happening here. You are trying to launch an app on streamlit share and you’re getting an import error?

Can you link your github repo here so we can see what is happening?

Can you also generate a minimum working example of code that produces this error will help us get to a solution faster! :racing_car: :racing_car: :racing_car:

Happy Streamlit-ing!
Marisa

Thanks @Marisa_Smith here is the GitHub link https://github.com/N-Harish/opencv-demo Yes when I deploy my app on streamlit share I get the above error.

1 Like

Hi @harish_natarajan -

For errors like this, around packages that are system-level, you need to add a packages.txt file to install drivers via the package manager:

For opengl issues specifically, this should resolve your issue:

3 Likes

Thanks @randyzwitch . It worked when I added packages.txt in my git repo. You guys are doing a great job developing streamlit and launching streamlit share. Thanks a lot.

Regards
Harish

2 Likes

Hi but this isnt working now

E: Unable to locate package freeglut3-dev
E: Unable to locate package libgtk2.0-dev
E: Couldn't find any package by glob 'libgtk2.0-dev
   '
E: Couldn't find any package by regex 'libgtk2.0-dev
   '
  Stopping...

did the same but nothing happening

face_more_web/packages.txt at master · arnavmehta7/face_more_web (github.com)

code above
plz assist

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

Traceback:

File "/home/appuser/.local/lib/python3.7/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)File "/app/face_more_web/app.py", line 3, in <module>
    import cv2File "/home/appuser/.local/lib/python3.7/site-packages/cv2/__init__.py", line 5, in <module>
    from .cv2 import *

further errors

Hi @arnavmehta7, welcome to the Streamlit community.

From the files you linked, it appears you are trying to deploy on Heroku. The packages.txt setup file is for Streamlit sharing.

Best,
Randy

No sir… I tried to deploy there as well as well as here… But the same problem

You also have this line

I don’t know for certain, but I suspect that having two - before headless breaks the pip install, which keeps the process from installing correctly. What do your installation logs show (it’s the icon on the bottom right of Streamlit share)

1 Like

Although it didn’t did anything wrong and i worked as soon i added headless and thanks everyone… I deployed 3 my websites which was pretty hard earlier now i know the process… THANKS!.. this is better than Heroku…!!! love streamlit… Continue adding more things❤️

2 Likes

Hi bro… I tired this but still getting errors…

Hey @ArunRengaraman did you specify matplotlib in requirements file?

Hello i think you does not have the package installed called matplotlib in your github repository make a requirements file with the name matplotlib… I’ve done the same project https://share.streamlit.io/arnavmehta7/lung_disease_web/main/st11.py check the source code of this one you will find the requirements file

yes … i have

I have added matplotlib in requirements file… please check it out…

Everything looks fine… Try to re deploy… And in the requirements file it should be opencv-python-headless nor opencv_python_headless

Still getting the same issue…

Hello,
Just for the info, I was facing the same error, adding packages.txt didn’t resolve the issue for me, but replacing opencv-python with opencv-python-headless in requirements.txt solved the issue.
Thanks for all the help :slight_smile:

1 Like

Thank You so much @randyzwitch , this fixed my issue.