Installing Python 3.6 in python:latest

Hello There.

I am currently building a Dockerfile, in which I need the latest Python version (3.9) and Python 3.6.

I chose python:latest as my base image, but when I try to install python 3.6 using apt I get “Unable to locate package …”.

The command I run:

RUN apt-get update
&& apt-get -y install python36 python36-devel python36-pip
&& apt-get clean all

I found a few discussions on the Internet where people had similar issues and adding apt-get update worked for them, but I still get the following error:

#9 0.238 Get:1 htt://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
#9 0.248 Get:2 htt://deb.debian.org/debian buster InRelease [121 kB]
#9 0.265 Get:3 htt://deb.debian.org/debian buster-updates InRelease [51.9 kB]
#9 0.361 Get:4 htt://security.debian.org/debian-security buster/updates/main amd64 Packages [243 kB]
#9 0.415 Get:5 htt://deb.debian.org/debian buster/main amd64 Packages [7906 kB]
#9 1.113 Get:6 htt://deb.debian.org/debian buster-updates/main amd64 Packages [7856 B]
#9 1.965 Fetched 8396 kB in 2s (4766 kB/s)
#9 1.965 Reading package lists…
#9 2.415 Reading package lists…
#9 2.857 Building dependency tree…
#9 2.951 Reading state information…
#9 2.996 E: Unable to locate package python36
#9 2.996 E: Unable to locate package python36-devel
#9 2.996 E: Unable to locate package python36-pip

failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c apt-get update && apt-get -y install python36 python36-devel python36-pip && apt-get clean all]: runc did not terminate sucessfully

Is there any other solution to this except for switching to another base image (like ubuntu) and installing both versions manually?

There is no package called python36 in Debian Buster.
Maybe it works better if you start from the standard Debian image and then install both python versions in the way you need them, because you’ll need 2 python entries in /usr/bin. You can take the Dockerfile for the official python image as a guideline.

1 Like