Docker build problem in Python

Hello,

i am trying to build a Docker-Desktop-Image for my Python Skript but when it gets to installing the Python packages, i get the Error:

ERROR: Could not find a version that satisfies the requirement aiohttp==3.8.4 (from versions: none)
ERROR: No matching distribution found for aiohttp==3.8.4
WARNING: There was an error checking the latest version of pip.

aiohttp is just an example, it is the same for other libraries like pandas.
I also checked the version of pip (3.11). I use Windows-Container (v. 4.13.1).
The Dockerfile looks like:

FROM python:3.11
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD ["python", "./app.py"]

It works, when I dont use Python Libraries.

Libraries can support different versions for different Python versions. To find out what is the latest supported version the easiest way I know is installing without version constraint and running pip freeze to get the version of the installed library so you can add that to the requirements file.

That is the version of PYthon, not pip the error is probably caused by the python version.

Ps: I added code blocks to your post, please use code formatting next time to help us to understand your question more easily.

1 Like

Thank you for your response. I created the requirements.txt with pip freeze > requirements.txt, so python created the .txt-file itself. I looked up so many sites but i could not find any solution yet. I tried a Code without Python libraries and it worked.

Did you run that command inside the container? If you ran it on the host you could have got a different result which doesn’t work in the container especially if the python version on the host is not the same as in the container, but the best is running it in the container.