14

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:pass@199.00.11.11:8080

C:\Users\user>SET PROXY=http://user:pass@199.00.11.11: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
  • 393
  • 2
  • 4
  • 16
  • I've tried with: pip install --proxy=NAN/user:pass@199.00.11.11:8080 datetime but I got the same error – SaCvP Apr 23 '18 at 16:24
  • Possible duplicate of [Proxy awareness with pip](https://stackoverflow.com/questions/30992717/proxy-awareness-with-pip) – craq Jun 18 '18 at 01:02
  • If you have Fiddler open, that might be the issue. Try closing it. – picklepirate28 Aug 23 '22 at 08:26
  • Set env variables in windows solved the problem http_proxy = http://user:pass@proxy:port https_proxy = http://user:pass@proxy:port – rinilnath Jun 16 '23 at 09:18

10 Answers10

8

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.

Lancer.Yan
  • 857
  • 13
  • 10
5

Try like this:

set HTTP_PROXY=http://199.00.11.11:8080
set HTTPS_PROXY=https://199.00.11.11:8080
Ankireddy
  • 179
  • 1
  • 6
  • 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/ – SaCvP Apr 23 '18 at 13:13
  • @SaCvP i got the same error as you. how did you solve the issue? – athos Jun 17 '19 at 08:12
  • 7
    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 ` – Ankireddy Jun 18 '19 at 09:20
  • When using --proxy keep in mind if you have special character in the username or password first escape them and then put them in the url. – Sadegh Ghanbari Apr 16 '23 at 12:42
2

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
adiga
  • 34,372
  • 9
  • 61
  • 83
2

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"

Mohit Sharma
  • 102
  • 9
2

Use the following code

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org datetime

You can change datetime with the name of any package you want.

Hadij
  • 3,661
  • 5
  • 26
  • 48
1

I recently had a similar issue doing pip3 install awscli on my local mac. I checked my env and there were no proxies set there. The solution that worked for me was disabling proxies from the network which got set on my machine for some reason. To do that

  1. Click on Wifi
  2. Open Network Preferences
  3. Click Advanced button
  4. Go to proxies tab
  5. Uncheck Web Proxy and Secure Web Proxy

Again, I know that network proxy misconfiguration is rare and this answer may not be the most suitable answer. But this might come in useful for some folks as this is right now the first link that comes on google search for pip install ProxyError.

Ankit Basarkar
  • 1,239
  • 3
  • 12
  • 13
1

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.

Suyash
  • 375
  • 6
  • 18
0

Try like: Go to *control panel --> Internet options --> Connections -->LAN Settings ->mark 'use proxy server for local address' options.

Andy
  • 1
  • 1
0

I ran into the same problem and the solution in my case was to unset the HTTPS_PROXY variable, because my proxy does not accept https requests.

I found the solution in this page : https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy

All proxy variables are set by the os admin :

HTTP_PROXY=http://my_domain:8888
NO_PROXY=*.internal_domain,172.*,
HTTPS_PROXY=http://my_domain:8888

To update pip for example, I have to run :

unset HTTPS_PROXY ; pip install -U pip
Alain Cherpin
  • 305
  • 4
  • 5
-2

If your proxy configration is OK,

It may be because your pip version is too high. Try to lower your pip version

python -m pip install pip==19.3.1

Then restart your terminal.

You can try this method to see if it works

boss zhu
  • 21
  • 1
  • Their problem was already solved. Also, how would a "too recent" version be a problem to proxies? – λuser Mar 17 '21 at 12:22
  • 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. – boss zhu Mar 17 '21 at 21:21
  • It worked for me, but I don' kown why. :)Maybe you can tell me . – boss zhu Mar 17 '21 at 21:28
  • 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. – λuser Mar 17 '21 at 22:04