我无法使用opencv2并收到ImportError:libgl.so.1无法打开共享对象文件,没有此类文件或目录

如何解决我无法使用opencv2并收到ImportError:libgl.so.1无法打开共享对象文件,没有此类文件或目录

** env:** ubuntu16.04 anaconda3 python3.7.8 cuda10.0 gcc5.5

命令:

conda activate myenv
python
import cv2

错误: 追溯(最近一次通话): 文件“”,第1行,位于 在第5行的“ /home/.conda/envs/myenv/lib/python3.7/site-packages/cv2/__init__.py”文件中 从.cv2导入* ImportError:libGL.so.1:无法打开共享库文件:没有这样的文件或目录

我尝试过:

RUN apt install libgl1-mesa-glx -y
    RUN apt-get install 'ffmpeg'\
        'libsm6'\
        'libxext6'  -y

,但这已安装并且是最新版本(libgl1-mesa-glx18.0.5-0ubuntu0〜16.04.1)。 然后我尝试了:

sudo apt-get install --reinstall libgl1-mesa-glx

它不起作用。 最后,我尝试删除该软件包:

sudo apt-get --purge remove libgl1-mesa-glx

发生了另一个错误:

Reading package list... Done
Analyzing the dependency tree of the package
Reading status information... Done
Some packages cannot be installed. If you are using an unstable distribution,this may be
Because the system cannot reach the state you requested. There may be some software you need in this version
The packages have not been created yet or they have been moved out of the Incoming directory.
The following information may be helpful in solving the problem:

The following packages have unmet dependencies:
 libqt5multimedia5-plugins: Dependency: libqgsttools-p1 (>= 5.5.1) but it will not be installed
E: Error,pkgProblemResolver::Resolve failed. This may be due to a software package being required to maintain the status quo.

任何帮助都将真正有用。谢谢。

conda列表:

# packages in environment at /home/lwy/.conda/envs/mmdet1:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
_openmp_mutex             4.5                       1_gnu    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
addict                    2.3.0                     <pip>
albumentations            0.5.1                     <pip>
appdirs                   1.4.4                     <pip>
asynctest                 0.13.0                    <pip>
attrs                     20.2.0                    <pip>
ca-certificates           2020.6.20            hecda079_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
certifi                   2020.6.20        py37he5f6b98_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
chardet                   3.0.4                     <pip>
cityscapesScripts         2.1.7                     <pip>
codecov                   2.1.10                    <pip>
coloredlogs               14.0                      <pip>
coverage                  5.3                       <pip>
cycler                    0.10.0                    <pip>
Cython                    0.29.21                   <pip>
decorator                 4.4.2                     <pip>
flake8                    3.8.4                     <pip>
future                    0.18.2                    <pip>
humanfriendly             8.2                       <pip>
idna                      2.10                      <pip>
imagecorruptions          1.1.0                     <pip>
imageio                   2.9.0                     <pip>
imgaug                    0.4.0                     <pip>
importlib-metadata        2.0.0                     <pip>
iniconfig                 1.1.1                     <pip>
isort                     5.6.4                     <pip>
kiwisolver                1.3.1                     <pip>
kwarray                   0.5.10                    <pip>
ld_impl_linux-64          2.35                 h769bd43_9    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libffi                    3.2.1                         1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
libgcc-ng                 9.3.0               h5dbcf3e_17    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libgomp                   9.3.0               h5dbcf3e_17    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libstdcxx-ng              9.3.0               h2ae2ef3_17    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
matplotlib                3.3.2                     <pip>
mccabe                    0.6.1                     <pip>
mmcv                      1.1.6                     <pip>
mmdet                     1.2.0+unknown             <pip>
ncurses                   6.2                  he1b5a44_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
networkx                  2.5                       <pip>
numpy                     1.19.4                    <pip>
opencv-python             4.4.0.46                  <pip>
openssl                   1.1.1h               h516909a_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
ordered-set               4.0.2                     <pip>
packaging                 20.4                      <pip>
Pillow                    6.2.2                     <pip>
pip                       20.2.4                     py_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pluggy                    0.13.1                    <pip>
py                        1.9.0                     <pip>
pycocotools               2.0                       <pip>
pycodestyle               2.6.0                     <pip>
pyflakes                  2.2.0                     <pip>
pyparsing                 2.4.7                     <pip>
pyquaternion              0.9.9                     <pip>
pytest                    6.1.2                     <pip>
pytest-cov                2.10.1                    <pip>
pytest-runner             5.2                       <pip>
python                    3.7.8           h6f2ec95_1_cpython    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
python-dateutil           2.8.1                     <pip>
python_abi                3.7                     1_cp37m    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
PyWavelets                1.1.1                     <pip>
PyYAML                    5.3.1                     <pip>
readline                  8.0                  he28a2e2_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
requests                  2.24.0                    <pip>
scikit-image              0.17.2                    <pip>
scipy                     1.5.3                     <pip>
setuptools                49.6.0           py37he5f6b98_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
Shapely                   1.7.1                     <pip>
six                       1.15.0                    <pip>
sqlite                    3.33.0               h4cf870e_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
tifffile                  2020.10.1                 <pip>
tk                        8.6.10               hed695b0_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
toml                      0.10.2                    <pip>
torch                     1.5.0+cu92                <pip>
torchvision               0.6.0+cu92                <pip>
tqdm                      4.51.0                    <pip>
typing                    3.7.4.3                   <pip>
ubelt                     0.9.3                     <pip>
urllib3                   1.25.11                   <pip>
wheel                     0.35.1             pyh9f0ad1d_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
xdoctest                  0.15.0                    <pip>
xz                        5.2.5                h516909a_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
yapf                      0.30.0                    <pip>
zipp                      3.4.0                     <pip>
zlib                      1.2.11                        0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

解决方法

通常这些包是作为系统包安装的,而不仅仅是 Python 包。因此,即使成功安装了 opencvcmakedlib 之类的软件包,很多时候它们也不起作用。

最好的方法是安装它们正在使用。

sudo apt-get install python3-opencv

这是在Ubuntu上成功安装opencv的首选方法Opencv Docs.

,

我已经解决了这个问题! 首先,找到文件:

find /usr -name libgl*

我找到了/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 然后,我创建了一个软链接:

ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so.1

最后,我确认它是有效的:

python
import cv2

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-