Python - Pip Install - Proxy Error - 'Cannot connect to proxy.', OSError'

39,490

Solution 1

Try like this:

set HTTP_PROXY=http://199.00.11.11:8080
set HTTPS_PROXY=https://199.00.11.11:8080

Solution 2

In my case, it was only because the 【VPN】 software modified the 【System Proxy】 configuration of the 【IE】 browser.

I modified it back in this way:

  1. open 【IE】
  2. Press 【Alt+X】 and scroll down to 【Internet options】
  3. Click on the 【Connections】 tab
  4. Press the 【LAN settings】 button
  5. Uncheck the 【Proxy Server】

This is how my problem was successfully solved.

Solution 3

I also faced this issue even with proxy, adding "--isolated" helped

For eg: pip install datetime --isolated

Note: My proxy is already set in "pip config"

Solution 4

First, install a proxy authentication service like CNTLM)

Second,

set http_proxy=http://username:password@proxyAddress:port
set https_proxy=https://username:password@proxyAddress:port

Solution 5

This works on Windows 10 for me:

  1. Search for Proxy Settings in Windows Start Search, open it

  2. Under Manual Proxy Setup, uncheck "Use a proxy server".

Alternatively, you may just add exceptions for the sources you want to install packages from.

Share:
39,490
SaCvP
Author by

SaCvP

Updated on July 23, 2022

Comments

  • SaCvP
    SaCvP almost 2 years

    I want to install some modules in a Enterprise VM in order to create some Python Scripts. I'm trying to use PIP with Proxy to do it. I'm using this command lines:

    C:\Users\user>SET HTTPS_PROXY=https://user:[email protected]:8080
    
    C:\Users\user>SET PROXY=http://user:[email protected]:8080
    
    C:\Users\user>pip install datetime
    

    To have access to my virtual machine I've this credentials:

    • USER: NAN/user
    • PASS: pass

    But I am getting this error:

    Collecting datetime
      Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /simple/datetime/
      Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /simple/datetime/
      Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /simple/datetime/
      Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /simple/datetime/
      Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /simple/datetime/
      Could not find a version that satisfies the requirement datetime (from versions: )
    No matching distribution found for datetime
    

    What I need to do in order to get the python module?

  • SaCvP
    SaCvP about 6 years
    I'm getting this: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )',))': /simple/datetime/
  • athos
    athos almost 5 years
    @SaCvP i got the same error as you. how did you solve the issue?
  • Ankireddy
    Ankireddy almost 5 years
    Try like: Go to *control panel --> Internet options --> Connections -->LAN Settings ->Unmark * 'use proxy server' options. Try using pip after this, it should work. or try pip --proxy http://user:pass@server:port install <package name>
  • λuser
    λuser about 3 years
    Their problem was already solved. Also, how would a "too recent" version be a problem to proxies?
  • Admin
    Admin about 3 years
    In the case that the proxy has been set up, there will still be proxy error on win10. Lowering the pip version is a feasible solution.
  • Admin
    Admin about 3 years
    It worked for me, but I don' kown why. :)Maybe you can tell me .
  • λuser
    λuser about 3 years
    If a newer version has a problem that an older version doesn't have, this is a regression, a bug that you should report to the pip project.