apk cannot find py-pip in an Alpine Docker image
ERROR: 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.
Fix it fast
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'2Match what you see, then jump to its fix
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-pip3Verify
Build the image and ask pip for its version.
docker build -t alpine-pip-test .
docker run --rm alpine-pip-test pip --versionConfirmed by pkgs.alpinelinux.org
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/repositories2Fix
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-pip3Verify
The search now finds the package.
apk search -e py3-pipConfirmed by docs.alpinelinux.org
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
Servers
Docker build fails with apk: not found in a Python or Ubuntu image
/bin/sh: 1: apk: not found
apk is the package manager of Alpine Linux only.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fixServers
Apache in a Docker container logs AH01114 when it proxies to a backend
AH01114: HTTP: failed to make connection to backend: api
Apache's proxy worker could not open a connection to the address in ProxyPass.
5 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix