Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

importerror: libgl.so.1: cannot open shared object file: no such file or directory (PyQt5)

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading