Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

apk cannot find py-pip in an Alpine Docker image

ErrorERROR: unable to select packages:

Short answer

On current Alpine releases there is no package called py-pip. The pip package is named py3-pip and lives in the main repository, so apk add py3-pip works. If the right name still fails, the package index is empty or the repositories file does not list the release you run. Run apk update and read /etc/apk/repositories.

  • Applies to Alpine 3.22, Docker Engine 28
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask apk what it knows. If the search for the old name is empty and the new name is found, it is a naming problem.

    docker run --rm alpine:3.22 sh -c 'apk update && apk search -e py-pip py3-pip'
  2. 2Match what you see, then jump to its fix

    1. 1unable to select packages: py-pip (no such package)The package was renamed to py3-pipFix
    2. 2unable to select packages even though the name is right (py3-pip (no such package))The package index is stale or the repositories file does not match the releaseFix

What does the error look like?

  • ERROR: unable to select packages:
  • py-pip (no such package):
  • required by: world[py-pip]

Cause 1 of 2

The package was renamed to py3-pip

1Check

The Alpine package search lists no package named py-pip, and lists py3-pip in the main repository. Old Dockerfiles and tutorials still use the Python 2 era name.

docker run --rm alpine:3.22 sh -c 'apk update && apk search -e py-pip py3-pip'

2Fix

Change the name in the Dockerfile. Use --no-cache so the image does not keep the package index.

FROM alpine:3.22
RUN apk add --no-cache py3-pip

3Verify

Build the image and ask pip for its version.

docker build -t alpine-pip-test .
docker run --rm alpine-pip-test pip --version

Confirmed by pkgs.alpinelinux.org

Did this fix it?

Cause 2 of 2

The package index is stale or the repositories file does not match the release

1Check

Print the repositories file. For a stable release it should list the main and community repositories of that same release. Lines for another release, or a missing file, leave apk with nothing to select from.

cat /etc/apk/repositories

2Fix

Correct the lines so they point at your release, then refresh the index. Do not mix branches, for example edge testing on top of a stable release.

apk update
apk add py3-pip

3Verify

The search now finds the package.

apk search -e py3-pip

Confirmed by docs.alpinelinux.org

Did this fix it?

How do I stop it coming back?

  • Pin the base image to a release tag such as alpine:3.22 instead of latest, so package names do not change under a build.
  • Use apk add --no-cache in Dockerfiles; it fetches a fresh index on every build.
  • Search with apk search -e name before copying a package name from an old tutorial.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.