Install specific version of python in docker

Viewed 10

I try to run container from image nvcr.io/nvidia/tensorflow:22.08-tf2-py3. But I have a problem.

The built docker-image contains python3.8. But I don't understand why I have this version of python in my docker-image. It is necessary to use python with version>=3.10 for correct work with libraries that I need. Version=3.8 is not explicitly specified in Dockerfile. When I try to install an another version:

RUN apt-get update && apt-get install -y software-properties-common && add-apt-repository ppa:deadsnakes/ppa && apt-get install -y python3.11
RUN python3.11 -m pip install --upgrade --no-cache -r requirements.txt

I get an error /usr/bin/python3.11: No module named pip during image building.

How can I correctly install specific version of python in my docker-image using Dockerfile?

1 Answers

You got Python 3.11 alright but you are missing the PIP module. Add python-pip or python3-pip to the list of packages you install with apt-get.

Related