Skip to content

pip “No matching distribution found” in an isolated build network

CI/CDtested on Nexus Repository OSS als PyPI-Spiegel, python:3.12-slim

“from versions: none” does not mean the version does not exist, but that pip got no list at all. In an isolated build network that is intended: packages only come through the internal mirror – pip just has to know it.

Symptom

docker run --rm --network seclab-intern \
  localhost:8082/library/python:3.12-slim \
  pip download --no-deps --retries 0 --timeout 5 -d /tmp flask==3.0.3
WARNING: ... Failed to establish a new connection: [Errno -3] Temporary
  failure in name resolution ...
ERROR: Could not find a version that satisfies the requirement flask==3.0.3
  (from versions: none)
ERROR: No matching distribution found for flask==3.0.3

A build container in the internal network tries to download straight from PyPI.

Diagnosis

The WARNING line before shows the real reason: name resolution or network unreachable. Instead of Errno -3 you may see [Errno 101] Network is unreachable – both mean: no way to the internet.

WARNING: ... Failed to establish a new connection: [Errno -3] Temporary
  failure in name resolution ...

Causes

from versions: nonepip gets no package list

Without a connection to the index pip knows not a single version – hence none.

Mirrorpip does not know the internal mirror

Without index-url pip asks pypi.org. In the isolated network only the mirror leads outside.

Fix

Create a pip.conf with index-url pointing to the mirror and mount it into the build container (trusted-host only because the lab uses HTTP):
[global]
index-url = http://nexus:8081/repository/pypi-proxy/simple
trusted-host = nexus
docker run --rm --network seclab-intern \
  -v "$PWD/pip.conf:/etc/pip.conf:ro" \
  localhost:8082/library/python:3.12-slim \
  pip download --no-deps -d /tmp flask==3.0.3
Looking in indexes: http://nexus:8081/repository/pypi-proxy/simple
Collecting flask==3.0.3
Saved /tmp/flask-3.0.3-py3-none-any.whl
Successfully downloaded flask

Don't: Do not give the build network internet access after all just so pip works – the mirror as the only source is the point.

▶
Break it yourself and find it – free
Secure supply chains hands-on, Chapter 3: mirrored sources – Nexus as the only source for images, PyPI, APT and npm.
Go to day 0 →

FAQ

Why is trusted-host in pip.conf?

Because the lab uses HTTP instead of HTTPS. In production Nexus sits behind TLS with your own PKI and trusted-host goes away.

Where does pip read /etc/pip.conf?

As system-wide configuration on every call; mounted as a volume it applies in the whole container.

Related error patterns

More