Find default pip index-url

2020-08-09 08:36发布

问题:

Is there a way to find which url(s) my pip command will look for when running something like pip install <package>?

You can configure files like .pip/pip.conf and .pypirc to modify that default but I'd like to know if there is a way to know the mirror priority.

Can I look for something specific running a command with the verbose flag (-v)?

回答1:

The help message for the install command will include the default value next to the --index-url option.

$ pip install -h
...
  -i, --index-url <url>       Base URL of Python Package Index (default https://pypi.python.org/simple).
...

The message may vary slightly depending on your version of pip. If an alternate address is configured, it will appear in that help message.

$ cat ~/.config/pip/pip.conf
[global]
index-url = https://my.local.mirror.com/simple
$ pip install -h
...
  -i, --index-url <url>       Base URL of Python Package Index (default https://my.local.mirror.com/simple).
...


回答2:

pip3 config list prints the config. Config file locations are documented https://pip.pypa.io/en/stable/user_guide/#config-file. For me, it was located in /etc/pip.conf.



标签: pip