skip to Main Content

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?

2

Answers


  1. 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.

    Login or Signup to reply.
  2. This is regarding your problem with python3.11 pip and not the tensor version support

    Looking at the original python3.11 docker in here you should be able to use the bellow code.

    # if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
    ENV PYTHON_PIP_VERSION 22.3
    # https://github.com/docker-library/python/issues/365
    ENV PYTHON_SETUPTOOLS_VERSION 65.5.0
    # https://github.com/pypa/get-pip
    ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/66030fa03382b4914d4c4d0896961a0bdeeeb274/public/get-pip.py
    ENV PYTHON_GET_PIP_SHA256 1e501cf004eac1b7eb1f97266d28f995ae835d30250bec7f8850562703067dc6
    
    RUN set -eux; 
        
        wget -O get-pip.py "$PYTHON_GET_PIP_URL"; 
        echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum -c -; 
        
        export PYTHONDONTWRITEBYTECODE=1; 
        
        python get-pip.py 
            --disable-pip-version-check 
            --no-cache-dir 
            --no-compile 
            "pip==$PYTHON_PIP_VERSION" 
            "setuptools==$PYTHON_SETUPTOOLS_VERSION" 
        ; 
        rm -f get-pip.py; 
        
        pip --version
    

    I was able to install pip for my python3.11 on Fedora(outside Docker) using python3 -m ensurepip (taken from here)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search