自学内容网 自学内容网

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

问题描述:

在服务器环境配置尝试导入 opencv (cv2) 模块时,系统找不到 libGL.so.1 这个共享库文件。这个问题通常出现在 Linux 系统中,特别是当系统缺少必要的图形库时。

(yolov11) python ./configs/yolov11/train.py
Traceback (most recent call last):
  File "/sxs/zhoufei/yolov11/./configs/yolov11/train.py", line 10, in <module>
    from ultralytics import YOLO
  File "/opt/conda/envs/yolov11/lib/python3.10/site-packages/ultralytics/__init__.py", line 11, in <module>
    from ultralytics.models import NAS, RTDETR, SAM, YOLO, FastSAM, YOLOWorld
  File "/opt/conda/envs/yolov11/lib/python3.10/site-packages/ultralytics/models/__init__.py", line 3, in <module>
    from .fastsam import FastSAM
  File "/opt/conda/envs/yolov11/lib/python3.10/site-packages/ultralytics/models/fastsam/__init__.py", line 3, in <module>
    from .model import FastSAM
  File "/opt/conda/envs/yolov11/lib/python3.10/site-packages/ultralytics/models/fastsam/model.py", line 5, in <module>
    from ultralytics.engine.model import Model
  File "/opt/conda/envs/yolov11/lib/python3.10/site-packages/ultralytics/engine/model.py", line 11, in <module>
    from ultralytics.cfg import TASK2DATA, get_cfg, get_save_dir
  File "/opt/conda/envs/yolov11/lib/python3.10/site-packages/ultralytics/cfg/__init__.py", line 10, in <module>
    import cv2
  File "/opt/conda/envs/yolov11/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/opt/conda/envs/yolov11/lib/python3.10/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/opt/conda/envs/yolov11/lib/python3.10/importlib/__init__.py", line 126, 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

解决方案:

apt install sudo
sudo apt-get update
sudo apt-get install libglvnd-dev libgl1

原文地址:https://blog.csdn.net/weixin_62828995/article/details/145188739

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!