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

【解决方法】libGL.so.1: cannot open shared object file: No such file or directory-CSDN博客

在配云端GPU服务器时,出现这个错误

File "/usr/local/lib/python3.6/dist-packages/cv2/__init__.py", line 8, in <module>
    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

解决方法(easy)

setup 에서 cv2 설치 오류가 발생합니다. · Issue #78 · Korea-Health-Datathon/KHD2020 · GitHub

卸载 pip uninstall opencv-python
安装 pip install opencv-python-headless

在Stack Overflow上有其他回答

Ubuntu系统

在docker中出错

将以下行添加到您的 Dockerfile:

# ubuntu系统
RUN apt-get update
RUN apt-get install ffmpeg libsm6 libxext6  -y

这些命令安装通常存在于本地计算机上的 cv2 依赖项,但可能会在您的 Docker 容器中丢失,从而导致问题。

libGL.so.1由 package 提供libgl1,所以添加一下代码

apt-get update && apt-get install libgl1

还有一些解决方案,例如

环境是ubuntu16.04。指令:
apt update
apt install libgl1-mesa-glx

这里说明了这个包的作用个,然后说了是Ubuntu16.0

FROM ubuntu:16.04
# 安装libgl库
RUN apt-get update && apt-get install -y libgl1-mesa-glx
# 安装其他必要的软件
RUN apt-get install -y software-properties-common && add-apt-repository ppa:jonathonf/python-3.6 && apt-get update && apt-get install -y python3.6 python3-setuptools python3-pip
# 设置Python3.6为默认版本
RUN ln -sf /usr/bin/python3.6 /usr/bin/python3 && ln -sf /usr/bin/python3 /usr/bin/python
# 安装其他必要的Python库
RUN pip3 install --no-cache-dir numpy opencv-python

CentOS系统

如果您使用的是 CentOS、RHEL、Fedora 或其他使用 的 linux 发行版yum,您将需要:

sudo yum install mesa-libGL -y

注意,这个安装包名和linux系统需要对应。否则,No package libgl1 available.

当前yum源找不到所需包,安装epel源即可

yum install -y epel-release

最终放在Dockerfile里是这样解决的,

USER root
RUN yum install -y mesa-libGL
RUN yum install -y mesa-libGL-devel # 安装这个最终解决

ImportError: libGL.so.1: cannot open shared object file: No such file or directory · Issue #10 · conda-forge/pygridgen-feedstock · GitHub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值