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:
- Global
-
If it exists then
${XDG_CONFIG_DIRS}/pip.conf
will be loaded, followed by/etc/pip.conf
. - User
-
${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. - Site
- For virtual environments then
${VIRTUAL_ENV}/pip.conf
pip.conf
pip.conf
should contain the following:
1[global]
2index = http://10.11.12.13:8081/repository/pypi-group/pypi
3index-url = http://10.11.12.13:8081/repository/pypi-group/simple
Where 10.11.12.13
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
- PyPI Repositories - SonaType Nexus 3
- PIP Configuration - Python Packaging Authority
Last modified February 11, 2022: Add PyPi repository config (f0fa478)