Import cv2 - opencv-python problem - ImportError: libGL.so.1

I use Python 3.10 Beta and installed the opencv-python package.
I wrote in the Server module:
import cv2
and I get the error:
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

What is the solution ?

Have you tried Googling this? I’ve seen it come up many times as opencv has dependencies that are not always present on the machine. That seems to be the case here as the error states.

yes @campopianoa is correct. opencv is a library written in C++.

The python version is just an interface to the C program, if that is not present on the system the python library has nothing to interface with.

Thanks for the reply.
Yes, i searched on Google, but they all advise to install some missing libraries locally, but as opencv-python is installed on the anvil server, these solutions didn’t help.
see for example : https://python1233.rssing.com/chan-44877200/article17518.html

The only thing, I tried now is to install opencv-python-headless instead of opencv-python. The first difference when i import cv2 in the server code, i have no error anymore, but i need to test further with a cv2 based function to see, if it is now solved.

I was just wondering if you had managed to resolve this as I am facing exactly the same issue.
Thanks.

You probably want to use a different machine and anvil-uplink if you want to use opencv written in C.

1 Like

Hello, I added package opencv-python-headless.
In the server module i could import cv2 and work with it normally. In my case I used it mainly to modify images.
Hope this helps you.

2 Likes