i've an issue: my corporate proxy kill every pip-installation. export http_proxy= doesn't works: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))

And pip install --proxy=... --trusted-host=... doesn't works too. Only if i use it together i can install somything from pip.

And it's in OS. When i use virtualenv it doesn't works even together. And i don't know, what to do. Please, help me.

Example, sudo pip install --proxy=... --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org sentry

Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)",)': /packages/bb/ee/edda27f5f59a98adb2aa1c0c939d7a15cada155eea73f5b56dc0b593deaa/sentry-9.0.0-py27-none-any.whl
Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/bb/ee/edda27f5f59a98adb2aa1c0c939d7a15cada155eea73f5b56dc0b593deaa/sentry-9.0.0-py27-none-any.whl (Caused by ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)",))
  • Hi, it's a bit unclear what you ask here. Could you read serverfault.com/help/how-to-ask and refine your question? Mainly by defining "does not work" and separating your expectations, your observations and goals would be a big help. – asdmin Feb 20 at 11:03
  • @asdmin update. – Antispam Antispam Feb 20 at 11:45

Your corporate proxy requires a username and password to be provided, but your http_proxy environment variable doesn't have them.

The http_proxy must be set with the username and password, for example:

  • sorry, but i know about it. And i write it --proxy=... Of cource i don't write actual host:port or my password... – Antispam Antispam Feb 20 at 14:56

There are probably multiple things happening concurrently:

  1. The error error('Tunnel connection failed: 407 Proxy Authentication Required',) indicates that you need authentication to use the proxy as explained by this answer.

  2. In addition to setting an environment variable http_proxy= you typically also need https_proxy= to instruct applications to use the proxy server for https connections.

  3. When executing commands with sudo the environment will be sanitized and most likely the http_proxy and https_proxy environment variables won't be available for the pip command.
    You can include a line such as Defaults env_keep = "http_proxy https_proxy ftp_proxy" at the start of /etc/sudoers to keep those user supplied environment variables.


My corporate proxy works so bad/unexpected way - it downloads to middle-server, and than gives me download. So, for terminal user (my computer) it looks like downloads aaborted. And it ruins with exeption ReadTimeoutError

So, i increase timeout and wait - and it installs as it needs.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.