docker 容器运行报libgl.so 缺失

 

用docker镜像运行paddle实例的时候,报一个libgl 的错误,说是找不到libgl.

Error: While importing 'app', an ImportError was raised:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/cli.py", line 234, in locate_app
    __import__(module_name)
  File "/ldasum/app.py", line 6, in <module>
    import paddlehub as hub
  File "/usr/local/lib/python3.8/site-packages/paddlehub/__init__.py", line 31, in <module>
    from paddlehub import datasets
  File "/usr/local/lib/python3.8/site-packages/paddlehub/datasets/__init__.py", line 15, in <module>
    from paddlehub.datasets.canvas import Canvas
  File "/usr/local/lib/python3.8/site-packages/paddlehub/datasets/canvas.py", line 23, in <module>
    from paddlehub.vision.utils import get_img_file
  File "/usr/local/lib/python3.8/site-packages/paddlehub/vision/utils.py", line 18, in <module>
    import cv2
  File "/usr/local/lib/python3.8/site-packages/cv2/__init__.py", line 8, in <module>
    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

这是容器里,可能是少一些包。

我们来给装上

RUN apt-get update && apt-get install -y libgl1-mesa-glx

然后再重新构建容器,运行,问题就没有了。

 

 

如果你还有问题,那么可能是你装的opencv版本的问题。

我们先删除旧的opencv-python,装上新的opencv-python-headless

python -m pip uninstall opencv-python
python -m pip install opencv-python-headless

分类: 默认 标签: 发布于: 2022-05-07 14:31:00, 更新于: 2022-05-07 14:33:49