Issue
I am trying to access my webcam with cv2(opencv-python) package.
When I try to import it I get this error:
Traceback (most recent call last):
File "server.py", line 6, in <module>
import cv2
File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 5, in <module>
from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
Note: I am trying to import this package on putty, on Linode server - that might be useful information.
If anyone can explain to me what is happening and maybe solve the problem I will highly appreciate it!
Solution
Install opencv-python-headless
instead of opencv-python
. Server (headless) environments do not have GUI packages installed which is why you are seeing the error. opencv-python
depends on Qt which in turn depends on X11 related libraries.
Other alternative is to run sudo apt-get install -y libgl1-mesa-dev
which will provide the missing libGL.so.1
if you want to use opencv-python
. The libgl1-mesa-dev
package might be named differently depending on your GNU/Linux distribution.
Full installation guide for opencv-python
can be found from the package documentation: https://github.com/skvark/opencv-python#installation-and-usage
Answered By - skvark
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.