pip install and custom index url

2020-07-09 09:53发布

问题:

I am getting the following exception while trying to install using pip:

Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(111, 'Connection refused'))': /simple/<package>/

Where does pip install the packages from?

How do I proxy or use alternate internal site to get these packages?

回答1:

pip install looks at http://pypi.python.org/simple/<package>/

You might see the following error in case the connection to pypi.python.org is not open to access (e.g. because of your firewall rules).

Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(111, 'Connection refused'))': /simple/<package>/

The -v option (enabling debug logging/verbose mode is a nice way to start debugging).

Often companies create a proxy to http://pypi.python.org/simple so all the internal sites can access it when they are not exposed to internet.

We can configure this url in pip.conf. By default pip looks into $HOME/.pip/pip.conf for configuration data.

[global]
extra-index-url = https://my-pypi.mywebsite.com/simple
timeout = 10

If you have set the conf and yet if the pip conf is not being picked check that pip.conf is in the right home directory for the user.

e.g. /root, / or /home/user



回答2:

This is what worked for me:

  1. unset all_proxy (optional in case none are set)
  2. pip install 'requests[socks]' inside the venv


回答3:

I bumped into this problem because https://pypi.org/ doesn't work over my current internet connection. Going through a VPN solved it for me.



标签: python pip pypi