我曾经使用conda yml文件在我的服务器上安装opencv,如下所示
name: project_environment
dependencies:
- python=3.6.2
- pip=20.2.4
- pip:
- pillow
- numpy
- opencv-python-headless==4.5.3.56
- torch
- torchvision
- face-alignment==1.3.4
- tensorflow==2.5.0
- cmake
- dlib
channels:
- anaconda
- conda-forge
之前,它可以正常工作,但是昨天我运行脚本时,出现错误
from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
如果我安装 python-opencv,而不是 headless 版本,应该会出现此错误。 我该如何调试,哪个包导致了问题。
最佳答案
谢谢skvark 。将您的建议作为答案发布以帮助其他社区成员。
Other alternative is to run
sudo apt-get install -y libgl1-mesa-dev
which will provide the missinglibGL.so.1
if you want to useopencv-python
. Thelibgl1-mesa-dev
package might be named differently depending on your GNU/Linux distribution.
您可以引用Error trying to import cv2(opencv-python) package , ImportError: libGL.so.1: cannot open shared object file: No such file or directory和 ImportError: libGL.so.1: cannot open shared object file: No such file or directory
您还可以引用 GitHub 上已关闭的问题:libGL.so.1: cannot open shared object file: No such file or directory
关于python - python-opencv-headless 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70120507/