skip to Main Content

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 ?

2

Answers


  1. Chosen as BEST ANSWER

    I have uploaded the file Dockerfile like this because I need the architecture of the container arm64

    FROM --platform=linux/arm64 python:3.8.10-slim
    COPY . /app
    ENV LIBGL_ALWAYS_INDIRECT=1unam
    

    but now I cant install pyqt5 library using

    apt-get install python3-pyqt5
    

    code in the container. Container give's me the error that is

    • Collecting PyQt5 Using cached PyQt5-5.15.9.tar.gz (3.2 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error

    × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [22 lines of output] Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in main() File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel whl_basename = backend.build_wheel(metadata_directory, config_settings) File "/tmp/pip-build-env-mwq0m6h0/overlay/lib/python3.8/site-packages/sipbuild/api.py", line 46, in build_wheel project = AbstractProject.bootstrap('wheel', File "/tmp/pip-build-env-mwq0m6h0/overlay/lib/python3.8/site-packages/sipbuild/abstract_project.py", line 87, in bootstrap project.setup(pyproject, tool, tool_description) File "/tmp/pip-build-env-mwq0m6h0/overlay/lib/python3.8/site-packages/sipbuild/project.py", line 586, in setup self.apply_user_defaults(tool) File "/tmp/pip-install-4lcxi4is/pyqt5_d62bb4d4ab2a424eae5f92329bee727e/project.py", line 68, in apply_user_defaults super().apply_user_defaults(tool) File "/tmp/pip-build-env-mwq0m6h0/overlay/lib/python3.8/site-packages/pyqtbuild/project.py", line 70, in apply_user_defaults super().apply_user_defaults(tool) File "/tmp/pip-build-env-mwq0m6h0/overlay/lib/python3.8/site-packages/sipbuild/project.py", line 237, in apply_user_defaults self.builder.apply_user_defaults(tool) File "/tmp/pip-build-env-mwq0m6h0/overlay/lib/python3.8/site-packages/pyqtbuild/builder.py", line 69, in apply_user_defaults raise PyProjectOptionException('qmake', sipbuild.pyproject.PyProjectOptionException [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

    × Encountered error while generating package metadata. ╰─> See above for output.

    note: This is an issue with the package mentioned above, not pip. hint: See above for details.



  2. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search