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

问题描述:

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

bug 复制代码
(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

解决方案:

bash 复制代码
apt install sudo
sudo apt-get update
sudo apt-get install libglvnd-dev libgl1
相关推荐
预测模型的开发与应用研究12 分钟前
AI编程工具横向评测--Cloudstudio塑造完全态的jupyter notebook助力数据分析应用开发
人工智能·jupyter·数据分析
i鹰斯坦爱吃红烧you22 分钟前
探索 Transformer²:大语言模型自适应的新突破
人工智能·pytorch·python·深度学习·语言模型·自然语言处理·transformer
云天徽上28 分钟前
【机器学习案列】基于朴素贝叶斯的垃圾短信分类
人工智能·机器学习·分类
Jozky8632 分钟前
自动驾驶&占用网格预测
人工智能·机器学习·自动驾驶
day day-up36 分钟前
1.17组会汇报
人工智能
油泼辣子多加1 小时前
Prompt-人工智能领域的核心技术与创新理念
人工智能·prompt
蜉蝣1号1 小时前
【已解决】我和ollama运行的qwen2.5大模型通信,总是返回GGGG?
人工智能·ai·语言模型·aigc
AI趋势预见1 小时前
AAPM:基于大型语言模型代理的资产定价模型,夏普比率提高9.6%
人工智能·深度学习·神经网络·语言模型·自然语言处理
安科瑞蒋静2 小时前
关于安科瑞Acrel-1000DP分布式光伏监控系统的实际案例分析-安科瑞 蒋静
大数据·人工智能
yzx9910132 小时前
OpenCV基础
人工智能·opencv·计算机视觉