Dependency Installation Failure in Dockerfile

I’m running into issues building my docker container in a deploy script. I’m running a job that uses the ubuntu-2004 machine executor.

To simply the issue, I’ve simplified my docker container to the barebones that (seem to) cause it to fail (at least, so far → I’m only on build step 2 of 27).
The first two steps (that RUN step is where it fails):

FROM python:3.8

RUN apt-get update && \
    apt-get install -yq \
        python2.7-dev python3.7-dev \
        python-pip \

It fails with an exit code of 100 and doesn’t give a reason that makes sense to me (this script works fine locally). Here’s the relevant stacktrace:

Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  python3-pip

E: Unable to locate package python3.7-dev
E: Couldn't find any package by glob 'python3.7-dev'
E: Couldn't find any package by regex 'python3.7-dev'
E: Package 'python-pip' has no installation candidate
E: Unable to locate package USER
E: Unable to locate package dev
The command '/bin/sh -c apt-get update &&     apt-get install -yq         python2.7-dev python3.7-dev         python-pip USER dev' returned a non-zero code: 100

I’ve been wracking my brain on this for two days now to no avail, and I would absolutely appreciate some insight into the problem.

With the Dockerfile:

FROM python:3.8

RUN apt-get update && \
      apt-get install -yq \
              python2.7-dev python3.7-dev \
              python-pip

and running

docker build .

I get

vagrant@vagrant:/tmp/x$ docker build .
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM python:3.8
3.8: Pulling from library/python
955615a668ce: Pull complete
2756ef5f69a5: Pull complete
911ea9f2bd51: Pull complete
27b0a22ee906: Pull complete
8584d51a9262: Pull complete
524774b7d363: Pull complete
9460f6b75036: Pull complete
9bc548096c18: Pull complete
1d87379b86b8: Pull complete
Digest: sha256:c2842aababbe377f9c76f172d9eb39487e23f306b2f29f020f3f6654cb0876e9
Status: Downloaded newer image for python:3.8
 ---> ff08f08727e5
Step 2/2 : RUN apt-get update &&       apt-get install -yq               python2.7-dev python3.7-dev               python-pip
 ---> Running in aba5c63aefa5
Get:1 http://deb.debian.org/debian bullseye InRelease [113 kB]
Get:2 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [36.8 kB]
Get:4 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [31.1 kB]
Get:5 http://deb.debian.org/debian bullseye/main amd64 Packages [8178 kB]
Fetched 8402 kB in 5s (1631 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  python3-pip

E: Unable to locate package python3.7-dev
E: Couldn't find any package by glob 'python3.7-dev'
E: Couldn't find any package by regex 'python3.7-dev'
E: Package 'python-pip' has no installation candidate
The command '/bin/sh -c apt-get update &&       apt-get install -yq               python2.7-dev python3.7-dev               python-pip' returned a non-zero code: 100

so I’m not 100% confident what you mean by "this script works fine locally.

What appears to be happening is that python:3.8 now points to python:3.8.12-bullseye. Bullseye doesn’t have the python-pip package anymore (Debian -- Software Packages in "bookworm", Subsection python), probably because python 2.7 was EOL January, 2020 and Debian finally decided to pull the plug.

Other than using python:2.7 which is still on Docker Hub as of this writing I’m not sure there’s many paths forward to actually installing python 2.7 anymore. You could in theory build a new base image based on a release of Debian that still has the packages but that’ll eventually go away, too.

Good luck!

Ah, yes. So, the actual problem was that I’m on 18.04 locally instead of 20.04. 20.04 deprecated python-pip and python3.7-dev. Replacing those packages with python3-pip and python-dev-is-python3, respectively, resolved my issue.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.