Search code examples
pythonlinuxubuntudockerfilearm64

Installing PYTHON3.8 and PyQt5 to the DOCKER CONTAINER with using DOCKERFILE


I have a project that contains a lot of library (requirements.txt) and I want to create a dockerfıle when I build this docker file in docker container I need python3.8 and ın python3.8 I need PyQt5 library.

When I create a simple dockerfile just consist of


FROM ubuntu:22.04

COPY . /app


The problem that I facing is when I try:


apt-get install python3-pyqt5


PyQt5 install python3.11 or python 3.10 and install PyQt5 in this directory.

But my project only run in python3.8 what should I do ?


Solution

  • Try this Dockerfile :

    FROM ubuntu:22.04
    
    ENV ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive
    RUN apt-get update &&\
        apt-get install -y software-properties-common &&\
        add-apt-repository ppa:deadsnakes/ppa && \
        apt-get update &&\
        apt-get install -y python3.8 &&\
        update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 10 &&\
        update-alternatives --set python3 /usr/bin/python3.8 &&\
        apt-get install -y python3-pyqt5