docker 打包 opencv-python,libGL.so.1 報錯解決方法

ponponon發表於2022-02-28

遇到下面的錯誤:

opencv ImportError: libGL.so.1: cannot open shared object file: No such file or directory

錯誤的教程:? docker環境裡安裝opencv ImportError: libGL.so.1: cannot open shared object file: No such file or directory
?????????????????????????????
圖片.png

正確的教程:?

FROM python:3.9-buster
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN (apt-get update) && (apt-get install -y libgl1-mesa-dev ffmpeg libsm6 libxext6)
RUN (/usr/local/bin/python -m pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple) && (pip install -i https://mirrors.aliyun.com/pypi/simple -r requirements.txt)
COPY . /code/

安裝這四個東西就好了:libgl1-mesa-devffmpeglibsm6libxext6

不要把 opencv-python 改為 opencv-python-headless

相關文章