我试图运行cv2,但当我试图导入它时,我得到以下错误:
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
建议的在线解决方案是安装
apt install libgl1-mesa-glx
但这是已经安装的最新版本。
注:我实际上是在Docker上运行这个,我无法检查OpenCV版本。我尝试导入matplotlib,导入正常。
我试图运行cv2,但当我试图导入它时,我得到以下错误:
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
建议的在线解决方案是安装
apt install libgl1-mesa-glx
但这是已经安装的最新版本。
注:我实际上是在Docker上运行这个,我无法检查OpenCV版本。我尝试导入matplotlib,导入正常。
当前回答
把这个放到Dockerfile中
RUN apt-get update
RUN apt install -y libgl1-mesa-glx
排队前
COPY requirements.txt requirements.txt
例如
......
RUN apt-get update
RUN apt install -y libgl1-mesa-glx
COPY requirements.txt requirements.txt
......
其他回答
在rocky linux 9中,我使用命令解决了这个错误 安装mesa-libGLU
在缺少各种图形库的非GUI服务器上使用pip3安装opencv后,在centos 8上出现了同样的问题。
DNF安装opencv
拉入所有需要的依赖项。
对我来说,唯一有效的WA是:
# These are for libGL.so issues
# RUN apt-get update
# RUN apt install libgl1-mesa-glx
# RUN apt-get install -y python3-opencv
# RUN pip3 install opencv-python
RUN pip3 install opencv-python-headless==4.5.3.56
下面是你需要的解决方案:
pip install -U opencv-python
apt update && apt install -y libsm6 libxext6 ffmpeg libfontconfig1 libxrender1 libgl1-mesa-glx
对我来说,这个问题与代理设置有关。对于pypi,我使用nexus镜像到pypi,对于opencv什么都不工作。直到我连接到另一个网络。