Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Add the following lines to your Dockerfile:

RUN apt-get update
RUN apt-get install ffmpeg libsm6 libxext6  -y

These commands install the cv2 dependencies that are normally present on the local machine, but might be missing in your Docker container causing the issue.


This is a little bit better solution in my opinion. Package python3-opencv includes all system dependencies of OpenCV.

RUN apt-get update && apt-get install -y python3-opencv
RUN pip install opencv-python

Even though the above solutions work. But their package sizes are quite big. libGL.so.1 is provided by package libgl1. So the following code is sufficient.

apt-get update && apt-get install libgl1

Put this in the Dockerfile

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

Before the line

COPY requirements.txt requirements.txt

For example

......

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

COPY requirements.txt requirements.txt

......