【问题解决】ImportError: libGL.so.1: cannot open shared object file: No such file or directory

一、问题

linux服务器,安装了opencv之后无法正常调用,报错如下
【问题解决】ImportError: libGL.so.1: cannot open shared object file: No such file or directory_第1张图片

二、解决方案

其实就是缺少依赖库首先运行

apt-get update

可以会出现如下情况,就是网速正常的情况下依然0%
【问题解决】ImportError: libGL.so.1: cannot open shared object file: No such file or directory_第2张图片
如果出现上述问题,我们需要换源

找到
/etc/apt/sources.list
然后把里面的内容换成如下内容

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

可能这些地址会变化,如果改成这些不管用了,可以在网上找最新的源

换完源之后,依次运行如下命令

apt-get update
apt-get install apt-file
apt-file update

然后寻找依赖库

apt-file search libGL.so.1

根据提示安装适合的依赖库

apt-get install xxx (xxx指提示的依赖库的名字)


参考博客
感谢以下博客的作者~
https://blog.csdn.net/liuyingying0418/article/details/84580254
https://blog.csdn.net/wjt199866/article/details/106386983/

你可能感兴趣的:(问题解决,opencv,ubuntu,linux)