PyPi repository mirrors

How to configure PIP use a PyPi repository mirror

Configuring PIP to use Nexus as a proxy is simple.

First ensure you've created the PyPi proxy.

Next, we need to edit or create pip.conf to hold the new index position. This file can be in one of three locations:

If it exists then ${XDG_CONFIG_DIRS}/pip.conf will be loaded, followed by /etc/pip.conf.
${HOME}/.config/pip/pip.conf for the specific user. There is a legacy option of ${HOME}/.pip/pip.conf which will be used if it exists.
For virtual environments then ${VIRTUAL_ENV}/pip.conf


pip.conf should contain the following:

2index =
3index-url =

Where is where you have deployed Nexus and pypi-proxy is what you called your PyPi proxy. If you've configured a group then use the group's name instead, e.g. pypi-group

Obviously if you've configured https and dns then use that and not port 8081.

Now any time you run pip it will use your proxy.

Further reading

Last modified February 11, 2022: Add PyPi repository config (f0fa478)