首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我不能使用opencv2并接收到ImportError: libgl.so.1不能打开共享对象文件,没有这样的文件或目录

我不能使用opencv2并接收到ImportError: libgl.so.1不能打开共享对象文件,没有这样的文件或目录
EN

Stack Overflow用户
提问于 2020-11-03 13:47:59
回答 3查看 18.3K关注 0票数 3

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

命令:

代码语言:javascript
复制
conda activate myenv
python
import cv2

"/home/.conda/envs/myenv/lib/python3.7/site-packages/cv2/__init__.py",错误:跟踪(最近一次调用): "",第1行,在文件第5行,在.cv2导入* ImportError: libGL.so.1:无法打开共享对象文件:没有这样的文件或目录

我试过:

代码语言:javascript
复制
RUN apt install libgl1-mesa-glx -y
    RUN apt-get install 'ffmpeg'\
        'libsm6'\
        'libxext6'  -y

但这已经安装了最新的version(libgl1-mesa-glx18.0.5-0ubuntu0~16.04.1).然后我试了一下:

代码语言:javascript
复制
sudo apt-get install --reinstall libgl1-mesa-glx

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

代码语言:javascript
复制
sudo apt-get --purge remove libgl1-mesa-glx

发生了另一个错误:

代码语言:javascript
复制
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.

任何帮助都是helpful.Thanks预先准备的.

conda列表:

代码语言:javascript
复制
# 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
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2020-11-04 03:33:36

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

代码语言:javascript
复制
find /usr -name libGL.so.1

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

代码语言:javascript
复制
ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so.1

最后,我验证了它的有效性:

代码语言:javascript
复制
# python
import cv2
票数 1
EN

Stack Overflow用户

发布于 2021-03-20 07:01:35

通常,这些块是作为系统包安装的,而不仅仅是Python包。因此,即使成功安装了opencvcmakedlib这样的软件包,也有很多次它们无法工作。

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

代码语言:javascript
复制
sudo apt-get install python3-opencv

按照官方的Opencv博士。,这是在Ubuntu上成功安装opencv的首选方法

票数 5
EN

Stack Overflow用户

发布于 2022-11-19 15:24:44

我通过以下途径解决了这个问题

代码语言:javascript
复制
apt-get install libgl1 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64664094

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档