I am trying to run a simple PyQt5 application on a docker container. But when I am running my docker compose file I am getting the following error:
from pyqt5.qtwidgets import * importerror: libgl.so.1: cannot open shared object file: no such file or directory.
Can someone help me fix this problem?
Dockerfile
FROM ubuntu:latest
# Preparing work environment
ADD server.py .
ADD hinto.py .
RUN apt-get update
RUN apt-get upgrade
RUN apt-get -y install python3
RUN apt-get -y install python3-pip
# Preparing work environment
RUN pip3 install PyQt5
as you can see I am installing the PyQt5 package so I do not understand where it got wrong.
CodePudding user response:
pip
isn't intended for installing native dependencies (like libgl, which is a C library, not a Python library). On Ubuntu, managing native dependencies is apt-get
's job.
Don't use pip
to install software your distro has its own packages for. In this case, that looks like:
apt-get -y install python3-pyqt5
As you can see at https://packages.ubuntu.com/jammy/python3-pyqt5, this lists libqt5gui5
as a dependency, which in turn depends on libgl1
.