How to setup pip to download from mirror repository by default?

Use pip3 config list -v to get list of locations where your pip.conf is located. Then go to one of the location(I prefer user) and add your URL. The file should look like this, if empty then add the lines.

[global]
index-url=https://pypi.org/simple
extra-index-url=<your_url>

In case if you want pip to look into your URL first then switch the places of url on above options.

[global]
index-url=<your_url>
extra-index-url=https://pypi.org/simple

using pip config, on user or global level. I have /etc/pip.conf configured like this:

[global]
index=https://my-company/nexus/repository/pypi-group/pypi
index-url=https://my-company/nexus/repository/pypi-group/simple
trusted-host=my-company

but you can configure this using pip config on user or global level, something like:

pip config --user set global.index https://my-company/nexus/repository/pypi-group/pypi
pip config --user set global.index-url https://my-company/nexus/repository/pypi-group/simple
pip config --user set global.trusted-host my-company

#NOTES

  • --index-url is used by pip install
  • --index is used by pip search

Tags:

Python

Pip

Pypi