【导入opencv 失败】ImportError: libGL.so.1: cannot open shared object file: No such file or directory

导入 cv2 失败,报错 ImportError: libGL.so.1: cannot open shared object file: No such file or directory
在这里插入图片描述

(model) [root@ai bin]# python
Python 3.7.5 (default, Oct 25 2019, 15:51:11)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/anaconda3/envs/model/lib/python3.7/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/root/anaconda3/envs/model/lib/python3.7/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/root/anaconda3/envs/model/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
>>> exit()

这个错误信息表明OpenCV在尝试加载时无法找到libGL.so.1这个共享库文件。libGL.so.1是OpenGL的一个库,用于图形渲染,OpenCV在处理某些图形操作时可能需要它。
解决办法:

sudo yum install mesa-libGL

在这里插入图片描述
再次验证,成功。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/u013421629/article/details/142059727