New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip doesn't respect proxy while installing packages from requirements file #1805

Closed
shredder12 opened this Issue May 8, 2014 · 85 comments

Comments

Projects
None yet
@shredder12
Copy link

shredder12 commented May 8, 2014

I'm using pip 1.5.5 on python 2.7.6, CentOS 6.5 x86_64. Python is compiled and installed in /usr/local/. While trying to install packages from requirements file, the first 12 packages are being downloaded via proxy, but after that pip tries to directly connect to the server instead of proxy and request fails.

$ export https_proxy=http://proxy:8080
$ /usr/local/bin/pip2.7 install -r reqs.txt

This results in download of first 12 packages via proxy, but the next one is a direct HTTPS request to the pypi server. I've validated this via packet trace and proxy logs.

Note that, the installation works flawlessly using /usr/bin/pip, v1.3.1.

Thoughts?

@dstufft

This comment has been minimized.

Copy link
Member

dstufft commented May 8, 2014

Is the one that is a direct HTTPS request to PyPI in a setup_requires somewhere?

@shredder12

This comment has been minimized.

Copy link
Author

shredder12 commented May 8, 2014

No, I don't think so. I checked in /tmp/pip_built_root directory. grep'd for 'setup_requires' in all setup.py/cfg files. Nothing. The installation failed as expected.

Let me know if there is a different way to verify it.

@dstufft

This comment has been minimized.

Copy link
Member

dstufft commented May 8, 2014

Is it a particular package that is reaching out to PyPI?

@shredder12

This comment has been minimized.

Copy link
Author

shredder12 commented May 8, 2014

Here are the contents of reqs.pip

requests==1.2.3
Flask==0.10.1
Flask-Login==0.2.7
Flask-Security==1.6.9
Flask-SQLAlchemy==1.0
Flask-Script==0.6.7
Flask-Principal==0.4.0
Flask-WTF==0.9.1
boto==2.3.0
suds==0.4
xmltodict==0.8.6
simplejson==3.3.3 
stripe==1.12.2
raven==4.1.1
Flask-Migrate==1.2.0
alembic==0.6.3

Installation fails at stripe. If I comment simplejson, it fails at raven. Here is the failure log. Note that, timeout is due to firewall dropping packets directly being sent to pypi server.

Downloading/unpacking stripe==1.12.2 (from -r /var/www/html/backend/reqs.pip (line 21))
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/req.py", line 1197, in prepare_files
    do_download,
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/req.py", line 1375, in unpack_url
    self.session,
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/download.py", line 546, in unpack_http_url
    resp = session.get(target_url, stream=True)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/requests/sessions.py", line 395, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/download.py", line 237, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/requests/sessions.py", line 383, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/requests/sessions.py", line 486, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg/pip/_vendor/requests/adapters.py", line 387, in send
    raise Timeout(e)
Timeout: (<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x1f70650>, 'Connection to pypi.python.org timed out. (connect timeout=15)')

@pcraston

This comment has been minimized.

Copy link

pcraston commented Jun 12, 2014

I'm having the same error. Strangely enough it installs a bunch of packages from the requirements file without problems but then fails with the VerifiedHTTPSConnection Timeout error.

@shredder12

This comment has been minimized.

Copy link
Author

shredder12 commented Jun 12, 2014

I couldn't find a solution for this. As a workaround, I used proxychains to enforce transparent proxy.

@Ivoz

This comment has been minimized.

Copy link
Member

Ivoz commented Jun 12, 2014

It would be awesome if we could get a simplest set of steps to reproduce this

@pcraston

This comment has been minimized.

Copy link

pcraston commented Jun 13, 2014

I run
pip install -r requirements.txt --proxy=<proxy address>

my requirements.txt contains 20 entries, it installs the first 16 without any problems and then throws the error:
Timeout: (<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x1f70650>, 'Connection to pypi.python.org timed out. (connect timeout=15)')

Interestingly enough it always fails when installing the 16. package (django-session-csrf==0.5)package but if I install the package manually using pip (not via the requirements.txt file) it works fine. If I run pip install -r requirements.txt --proxy=<proxy address> again after that it obviously skips django-session-csrf but then installs the following package without problems and then fails with the Timeout error on the package after that.

Increasing the timeout to something like 300 doesn't help.

@ikhere

This comment has been minimized.

Copy link

ikhere commented Jun 17, 2014

I'm facing same issue on CentOS 6.4 with Python 2.6.6 and pip 1.5.6. Any idea how to get a workaround?

@pcraston

This comment has been minimized.

Copy link

pcraston commented Jun 20, 2014

Seems like it is always the 15th item in the requirements file. If I comment out earlier items, it times out on a later item than previously...

Tried with pip 1.5.4 and 1.5.6 on Ubuntu 14.04 LTS

@pfmoore

This comment has been minimized.

Copy link
Member

pfmoore commented Jun 20, 2014

@pcraston could it be some sort of rate limiting on your proxy? With the requirements file pip is sending too many requests in a short period of time?

@pcraston

This comment has been minimized.

Copy link

pcraston commented Jun 20, 2014

Just spoke to our IT manager he says there is no rate limiting on our proxy. But it does seem odd!

@shredder12

This comment has been minimized.

Copy link
Author

shredder12 commented Jun 20, 2014

Its doesn't seem to be enforced by proxy. If you monitor the outgoing
traffic, you'll see that for some reason pip starts sending direct requests
to the web server. Hence, the requests either time out or are
refused(depending on network setup).

@nullprobe

This comment has been minimized.

Copy link

nullprobe commented Jun 24, 2014

I can confirm I have the same issue. Installing threatstream/mhn with the requirements file.

@dstufft

This comment has been minimized.

Copy link
Member

dstufft commented Jun 24, 2014

This appears to be a requests bug, I've redirected this to upstream here: kennethreitz/requests#2110

@dstufft

This comment has been minimized.

Copy link
Member

dstufft commented Jun 24, 2014

Or perhaps urllib3.

@dstufft

This comment has been minimized.

Copy link
Member

dstufft commented Jun 24, 2014

Ok requests has kicked this back to us, it appears it might actually be a PyPI/Fastly issue.

@dstufft

This comment has been minimized.

Copy link
Member

dstufft commented Jun 25, 2014

Can folks getting this issue run this script with requests 2.3.0?

import requests
session = requests.Session()
for i in range(100):
    print(i)
    session.get("https://pypi.python.org/simple/").content

and report back if it fails and where it fails?

Also if you can report back with the name of your proxy software and version or any other information of the like that we can use to try and reproduce.

Also if you can go to http://debug.fastly.com/ and post the encrypted block at the top so I can forward it to Fastly that would be great as well.

@dstufft

This comment has been minimized.

Copy link
Member

dstufft commented Jun 25, 2014

Oh, if the above script fails, can you also try it with https://imgur.com/ and https://google.com/

@dstufft

This comment has been minimized.

Copy link
Member

dstufft commented Jun 25, 2014

Also can you clarify that there is no address based restriction on rate limiting or the like? For example the IP addresses associated with PyPI are also associated with a lot of other sites that Fastly hosts like imgur so could the proxies be denying based on the IP addresses?

@nullprobe

This comment has been minimized.

Copy link

nullprobe commented Jun 26, 2014

So I ran the little script and after 20sec of displaying content I get the following error :

51
Traceback (most recent call last):
File "", line 3, in
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 468, in >get
return self.request('GET', url, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 456, in >request
resp = self.send(prep, *_send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 559, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 378, in send
raise ProxyError(e)
requests.exceptions.ProxyError: ('Cannot connect to proxy.', error(110, 'Connection timed out'))

Our corporate proxy doesn't have rate limiting or address based restrictions.

@shredder12

This comment has been minimized.

Copy link
Author

shredder12 commented Jun 26, 2014

Just like above, the script failed on 52nd requests for both pypi and imgur. Google worked fine.

49
50
51
Traceback (most recent call last):
File "/tmp/pypitest.py", line 5, in
session.get("https://pypi.python.org/simple/").content
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 468, in get
return self.request('GET', url, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 456, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 559, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 378, in send
raise ProxyError(e)
requests.exceptions.ProxyError: ('Cannot connect to proxy.', error(111, 'Connection refused'))

The proxy is configured to refuse in case a direct connection is attempted, hence 111. There is no rate limiting AFAIK. Furthermore, I can confirm that I've faced the same situation on two different proxy deployments - both squid, running version 3.1.10 on centos.

Response from debug.fastly.com

H4sIAAAAAAAAA31SXU/bMBT9K1GeNlan+WxTKqRloYVsNFSkICZVQm7iJhaJ3dkOTUH8912HaRVi
muQH+55zj6+Pz4tZEVwQIc3TF/OSS2WemgXZtKW1xVLVByvnjTkwbyURKCoJ0/iCP9O6xuthYNnG
p3vHmRq3m5apdmpcUdZ2RheOHkb+1BBPp+7Esj8bFyR/5Ouhazs2LMeYU0G2vIMKwCAf5TnZaWlF
OrUeVqqpB3i3q2mOFeVsPex06Uv3odzU019ntjUZnKyHJ/02/CuHrjArW1wS0CUM3WYDwnpKAJQY
5xVBMWdK8BoIDe4QUM/cYOLax5HQjOW8oKwESvlMdwDMe19QXFNwAyVLQBzfcryJFbrWCAj3aEUb
IqCeOb7tjcd+6DmWB8JOMBkHg7vMPspcEJ4sYQ6wTxxiXuhhk/SIZ0Q8gfVv19ie5fqB5bqu5YT+
kbQizQ7dz+f/GOUOC0ZlpZHQD7xx6HhBD8y52GNRkELvPjT+Ee4l894q+TRyUfY99szXgbmvOJUP
jKg9F486ORT2rG3e6dgGMo4nzwFZhhv9wHQxS+IVSpJkhS5/ngMgFVYtZNCMsiy5SGfnRnqdouX1
zSr6djXTnVzR7UF/1GYnsMTFV0qpsnBuUQZwA1+x0fAiStIVuskWUZqg9EeKejM1XPN9/ylvjHeQ
4K0i8r/dVOh4JjfQ+WH4vIKgkQJwCLiPbBe52mPJW5Hr50bLNImPtvE904O8mFyUmNHnPstanCki
WH/CtZEwqaiCuQy+hcOWi6aHjBXJK8ZrXh7gDlwUgkj5FprX19+sUp+UzgMAAA==

@pcraston

This comment has been minimized.

Copy link

pcraston commented Jun 30, 2014

It also fails on 52nd request for me on https://pypi.python.org/simple/ and https://imgur.com/ (but with a different error than @shredder12 and @nullprobe -- see below):

50
51

ProxyError                                Traceback (most recent call last)
<ipython-input-21-788947201a19> in <module>()
      1 for i in range(100):
      2     print (i)
----> 3     session.get("https://pypi.python.org/simple/").content
      4 

/home/vagrant/venv/local/lib/python2.7/site-packages/requests/sessions.pyc in get(self, url, **kwargs)
    393 
    394         kwargs.setdefault('allow_redirects', True)
--> 395         return self.request('GET', url, **kwargs)
    396 
    397     def options(self, url, **kwargs):

/home/vagrant/venv/local/lib/python2.7/site-packages/requests/sessions.pyc in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert)
    381             'allow_redirects': allow_redirects,
    382         }
--> 383         resp = self.send(prep, **send_kwargs)
    384 
    385         return resp

/home/vagrant/venv/local/lib/python2.7/site-packages/requests/sessions.pyc in send(self, request, **kwargs)
    484         start = datetime.utcnow()
    485         # Send the request
--> 486         r = adapter.send(request, **kwargs)
    487         # Total elapsed time of the request (approximately)
    488         r.elapsed = datetime.utcnow() - start

/home/vagrant/venv/local/lib/python2.7/site-packages/requests/adapters.pyc in send(self, request, stream, timeout, verify, cert, proxies)
    379 
    380         except _ProxyError as e:
--> 381             raise ProxyError(e)
    382 
    383         except (_SSLError, _HTTPError) as e:

ProxyError: Cannot connect to proxy. Socket error: [Errno 110] Connection timed out.

All works fine when sending requests to https://google.com

Proxy is squid version 3.1.20 running on Debian

http://debug.fastly.com/ output:

H4sIAAAAAAAAA21SXW/aMBT9K1b20nY4xIFAaNUHlgKL1AZE0q8JaXIdN1hLbOo4BVr1v+863cam
VcqDc8+5536dV2fNac517Zy+Ol9VbZxTJ+cPTeE+0tqUe5epyuk41zXXeFxwafEr9SLKkq66geuh
o1shc7WtUZKhgUvO0O38dtA/Q/r5tOe53jGacfZDrbq+Rzz4CJoKzR/VbtW1MEiPGeMbK2v4zqy6
a1OVHbrZlIJRI5RcdXc29Hn3X7gqz57OPXfUOVl1T9pn+EcOX1JZNLTgoMslLh46XLaUACg3gkKY
uASVitFyDVOjo/qpETk05RLX946BFVG25jhS0mhVAr+iOwyC534w8r1D43gimcqFLIBSvIgNANN2
czgqBewLxwtAQt8dQsEQNjQYAuUOZ6LiGpCU9L0+6ZF+ELohGfaG4WgUdm5S7yA04ypeQCcNtLKP
VG6Hmn054CnXz3CethAJA7dnK8EXHCgZrzb4bjr9sJUbqqWo1zabDEkAd/IGLTBVekt1znP7+iD1
l3gry9p1lWxPiB/gy+jeees427US9XfJzVbpH9ZhAt6yqf7V8kOE0V//IwLaklZ2zm+TpHXOkPTw
xXiJo3mSTe6yOJnOl1fjLJ4n6SS6XsbZPeSw9xX9Xk9tqGnA2M44TeNZMrlAizGEKzjKw/5dGyfz
CF8lmWWrRjNbchkvJugT+LQ0XPP8MIfaSnuyV0fpgkrx0hoREqxHwLsolo9KV20UpZw1Wpg9ujSg
8PYTBBarvWcDAAA=

@bitsrfr

This comment has been minimized.

Copy link

bitsrfr commented Jun 30, 2014

Fails on 52 attempt. As above works fine with https://google.com.

Running Ubuntu 12.04 running in host-only mode on VirtualBox, proxying through wingate on Windows 8.1 host.

Traceback (most recent call last):
File "/tmp/test.py", line 5, in
session.get("https://pypi.python.org/simple/").content
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 468, in get
return self.request('GET', url, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 456, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 559, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 378, in send
raise ProxyError(e)
requests.exceptions.ProxyError: ('Cannot connect to proxy.', error(101, 'Network is unreachable'))

H4sIAAAAAAAAA21T70/bMBD9V6x8AhanSZ2kBMSHLsCK+FXRQpHWaXKTI7Wa2Jnjri2o//vOKaOT
hqxI8Xu+d8935zdnDjwH3Tgnb85ANcY5cXKYLQvvhTem3HiZqhzX6WcZ1JYzsDbTztxUpcvruhQZ
N0LJaWdtoS/r/+CqPP115nuJKypewLSzglntHk07Ry18jNKPDWjaL0Ba+Vv1KsqSTzuR55ODiZC5
WjXkbkxij52Syf0kDg9JHzPABGbXAq1ErOexmBxcD8a3Ny4pxQLIN8gW6pCkc60qzMlQzAuSIPaC
iJERf+Fa/A38uBu94bJYokd0AZI+jlyQHx5Tns2BpkoarUo8UPE1bQwv4cxH9pl+LZeQKm7ok+A2
Pghj1gNgAc9mLMn3SS5kpnIhCzxUvIoaicu2zDQtBVaAXg2RCSKv6zOvy5jXi1v9sahAIzMKQj8M
wpDFzEvCOOyGSRy4TyN/L/QN1NUQrS7R6yZVub3P42jPj0D/xoK3ibo2SeSFWJ3jcH9kDFVNny8v
P7XyxLUUzRy5417SQydR1OKXSq+4ziG3f59Evmu3qllbTqXzoMe69P7h3Nm6zmquRPNTglkpvbDT
KPBfLqudlm8XocTKRh8f6kpe2SsOhvTqbnzxcHcxRnDOZV5aGLc0iKjfrgAZ7JpZ4rA750JDZki/
aUQhKzt9rpNp4AZymzFJQur3qG9jMpQrWrjrBwgz6kd7x2olbW/eHKULLsVrO/nWEaxKMIYOebbA
wpBUVTWXm3/dDYa443muoWnfX2M0AD6D7w7zfZ8MuFTYKzLawT/QiTAbjBvyUpF+adT7haxW2sdN
ne0anoTMtw3NdmOwG4HtdvsHvEQyo+4DAAA=

@alexandrem

This comment has been minimized.

Copy link

alexandrem commented Jul 2, 2014

Hi,
I've encountered the same problem in my Vagrant environment, running CentOS 6.5 and pip 1.5.6 with our corporate proxy.

This seems to happen randomly on big requirements.txt that I try to install with pip when using the https proxy.

After investigation, I found that the problem seems to lie in the PoolManager of urllib3 that is embedded in the pip installation (_vendor/requests/packages/urllib3/poolmanager.py:ProxyManager)

I found a quick fix in the code that make my installation passes correctly.

To confirm what I'm saying, just change this single line in the following file of your pip installation:

$ diff /opt/venvs/ironic/lib/python2.6/site-packages/pip/_vendor/requests/adapters.patch.py /opt/venvs/ironic/lib/python2.6/site-packages/pip/_vendor/requests/adapters.py
209c209
<             if True or not proxy in self.proxy_manager:
---
>             if not proxy in self.proxy_manager:

The pip install works correctly afterward when instantiating a new ProxyManager object every time.

Here is an example of error that I used to have for my pip install:

$ pip install -r requirements.txt
....
Downloading/unpacking pecan>=0.4.5 (from -r requirements.txt (line 25))
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/opt/venvs/ironic/lib/python2.6/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/opt/venvs/ironic/lib/python2.6/site-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/opt/venvs/ironic/lib/python2.6/site-packages/pip/req.py", line 1197, in prepare_files
    do_download,
  File "/opt/venvs/ironic/lib/python2.6/site-packages/pip/req.py", line 1375, in unpack_url
    self.session,
  File "/opt/venvs/ironic/lib/python2.6/site-packages/pip/download.py", line 546, in unpack_http_url
    resp = session.get(target_url, stream=True)
  File "/opt/venvs/ironic/lib/python2.6/site-packages/pip/_vendor/requests/sessions.py", line 468, in get
    return self.request('GET', url, **kwargs)
  File "/opt/venvs/ironic/lib/python2.6/site-packages/pip/download.py", line 237, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/opt/venvs/ironic/lib/python2.6/site-packages/pip/_vendor/requests/sessions.py", line 456, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/venvs/ironic/lib/python2.6/site-packages/pip/_vendor/requests/sessions.py", line 559, in send
    r = adapter.send(request, **kwargs)
  File "/opt/venvs/ironic/lib/python2.6/site-packages/pip/_vendor/requests/adapters.py", line 384, in send
    raise Timeout(e, request=request)
Timeout: (<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x2802e50>, 'Connection to pypi.python.org timed out. (connect timeout=15)')

Storing debug log for failure in /root/.pip/pip.log

For the curious, the requirements.txt file I was testing is this one:
https://github.com/openstack/ironic/blob/master/requirements.txt

@dstufft

This comment has been minimized.

Copy link
Member

dstufft commented Jul 2, 2014

Hey @alexandrem I'm not sure I'm groking what you've actually changed. Was it in pip/_vendor/requests/adapters.py? Or a different file?

@alexandrem

This comment has been minimized.

Copy link

alexandrem commented Jul 2, 2014

Yes my test change was in pip/_vendor/requests/adapters.py

@alexandrem

This comment has been minimized.

Copy link

alexandrem commented Jul 2, 2014

Sorry the diff was reverse, but basically I just add a True to the condition on line 209 of the adapter.py to always create a ProxyManager instance, thus skipping the pool manager logic.

@sigmavirus24

This comment has been minimized.

Copy link
Member

sigmavirus24 commented Jul 2, 2014

If everyone who has run @dstufft's script above can try out the following script, it would help us narrow down the problem. First, if you can determine which proxy requests is utilizing, grab that

from requests.packages.urllib3 import ProxyManager

proxy_url = 'http://localhost:8080'  # Just an example, place your proxy URL here please

pool = ProxyManager(proxy_url)
for i in range(100):
    print(i)
    pool.request("GET", "https://pypi.python.org/simple/", headers={'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*'}).read()

This is roughly the equivalent to what requests sends.

@dstufft dstufft closed this May 5, 2015

@jefftucker

This comment has been minimized.

Copy link

jefftucker commented Jul 13, 2015

I'm seeing identical behavior to what everyone is reporting here in Pip 7.1 (installed by default with the installer for Python 2.7.10) on Windows 7. Is this the same issue? Was this fixed on Windows?

@AndiEcker

This comment has been minimized.

Copy link

AndiEcker commented Aug 11, 2015

I also get this problem from within our company Windows network with different versions of pip.

Using pip 6.0.8 from C:\Python34\lib\site-packages (python 3.4) I get this output on the console:

C:\src\set>c:\Python34\Scripts\pip.exe install cx_Freeze
Collecting cx-Freeze
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connec
tion broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connectio
n failed: 407 Proxy Authentication Required ( The ISA Server requires authorizat
ion to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /
simple/cx-freeze/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connec
tion broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connectio
n failed: 407 Proxy Authentication Required ( The ISA Server requires authorizat
ion to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /
simple/cx-freeze/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connec
tion broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connectio
n failed: 407 Proxy Authentication Required ( The ISA Server requires authorizat
ion to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /
simple/cx-freeze/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connec
tion broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connectio
n failed: 407 Proxy Authentication Required ( The ISA Server requires authorizat
ion to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /
simple/cx-freeze/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connec
tion broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connectio
n failed: 407 Proxy Authentication Required ( The ISA Server requires authorizat
ion to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /
simple/cx-freeze/
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connec
tion broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connectio
n failed: 407 Proxy Authentication Required ( The ISA Server requires authorizat
ion to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /
simple/cx-freeze/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connec
tion broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connectio
n failed: 407 Proxy Authentication Required ( The ISA Server requires authorizat
ion to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /
simple/cx-freeze/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connec
tion broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connectio
n failed: 407 Proxy Authentication Required ( The ISA Server requires authorizat
ion to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /
simple/cx-freeze/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connec
tion broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connectio
n failed: 407 Proxy Authentication Required ( The ISA Server requires authorizat
ion to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /
simple/cx-freeze/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connec
tion broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connectio
n failed: 407 Proxy Authentication Required ( The ISA Server requires authorizat
ion to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /
simple/cx-freeze/
  Could not find any downloads that satisfy the requirement cx-Freeze
  No distributions at all found for cx-Freeze

Using pip 1.0.1 from c:\python27\lib\site-packages (python 2.7) I got this pip.log file content:==

------------------------------------------------------------
C:\Python27\Scripts\pip-script.py run on 08/11/15 16:36:48
Downloading/unpacking cx-Freeze
  Getting page http://pypi.python.org/simple/cx_Freeze
  Could not fetch URL http://pypi.python.org/simple/cx_Freeze: HTTP Error 407: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )
  Will skip URL http://pypi.python.org/simple/cx_Freeze when looking for download links for cx-Freeze
  Getting page http://pypi.python.org/simple/
  Could not fetch URL http://pypi.python.org/simple/: HTTP Error 407: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )
  Will skip URL http://pypi.python.org/simple/ when looking for download links for cx-Freeze
  Cannot fetch index base URL http://pypi.python.org/simple/
  URLs to search for versions for cx-Freeze:
  * http://pypi.python.org/simple/cx_Freeze/
  Getting page http://pypi.python.org/simple/cx_Freeze/
  Could not fetch URL http://pypi.python.org/simple/cx_Freeze/: HTTP Error 407: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )
  Will skip URL http://pypi.python.org/simple/cx_Freeze/ when looking for download links for cx-Freeze
  Could not find any downloads that satisfy the requirement cx-Freeze
No distributions at all found for cx-Freeze
Exception information:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\pip\basecommand.py", line 126, in main
    self.run(options, args)
  File "C:\Python27\lib\site-packages\pip\commands\install.py", line 223, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "C:\Python27\lib\site-packages\pip\req.py", line 954, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "C:\Python27\lib\site-packages\pip\index.py", line 152, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for cx-Freeze
@mandshaw

This comment has been minimized.

Copy link

mandshaw commented Nov 5, 2015

This is still an issue in pip version 7.1.2.

I am seeing it for index_urls though.

For example if you try and download pandas from an index, pandas will require numpy which pip will then try and get from PYPI instead of the specified index_url

details are:

Python 2.7
Pip 7.1.2
Redhat Centos 6.6

@iamnagesh

This comment has been minimized.

Copy link

iamnagesh commented Mar 23, 2016

@AndiEcker, Have you found any solution for that problem? Even I face the same issue from my office. Very much appreciate your help.

This is the error:

  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connec
tion broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.conne
ction.VerifiedHTTPSConnection object at 0x00000000033A19E8>, 'Connection to pypi
.python.org timed out. (connect timeout=15)')': /simple/pydicom/
@AndiEcker

This comment has been minimized.

Copy link

AndiEcker commented Mar 23, 2016

@iamnagesh : the solution for my case was that our network administrator had to gave me access to the internet without a proxy.

But your error message is looking different anyway - sorry but don't know why your connection is showing a timeout error - if you have a slow internet connect then maybe try to increase the timeout (unfortunately I don't know how to do this).

@alexandrem

This comment has been minimized.

Copy link

alexandrem commented Mar 23, 2016

For the previous errors involving http proxy authentication via NTLM, I would suggest using cntlm as a workaround.

Setting it locally with a NTLM hash for your proxy password really solves a lot of different issues with apps and libraries that don't support very well corporate http/https proxies.

You just have to set your proxy env vars and app settings to http://localhost:3128

@ashi-taka

This comment has been minimized.

Copy link

ashi-taka commented Apr 6, 2016

@iamnagesh I am facing the same error while installing a package through pip in anaconda prompt.
I set up environmental variable HTTP and HTTPS for proxy. Still I have same error. Can you please tell what you did to solve the issue.

@AndiEcker

This comment has been minimized.

Copy link

AndiEcker commented Apr 6, 2016

@ashi-taka: in my case our network admins fixed it for me and AFAIR the fix
was that our network admins totally removed any proxy in our company
network.

2016-04-06 6:00 GMT+01:00 ashi-taka notifications@github.com:

@AndiEcker https://github.com/AndiEcker I am facing the same error
while installing a package through pip in anaconda prompt.
I set up environmental variable HTTP and HTTPS for proxy. Still I have
same error. Can you please tell what you did to solve the issue.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1805 (comment)

@prabhakar9885

This comment has been minimized.

Copy link

prabhakar9885 commented Aug 26, 2016

Though the proxy confiuration was added at system level, due to some reason pip was was giving the error [Errno 101] Network is unreachable

Using proxy option fixed the issue.( thanks to @pcraston )

sudo pip install pandas --proxy=proxy:8080

Ubuntu 14.04
pip 8.1.2

@AverageS

This comment has been minimized.

Copy link

AverageS commented Nov 10, 2016

Running pip with --isolated key solved the problem for me.
pip3 8.1.1

@genesem

This comment has been minimized.

Copy link

genesem commented May 11, 2017

Got the same errors with pip 9.0.1 @ windows 10
Problem was with proxy, it was set as "" (empty, but flagged as used proxy) at system wide level.

@andreamussap

This comment has been minimized.

Copy link

andreamussap commented May 17, 2017

[update] It worked! I've found the line, it's now 178. Thanks.


Hi all
can somebody help me? I've tried to install mkdocs and got this error:

C:\Users\Lenovo Local>pip install mkdocs
Collecting mkdocs
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x0000014999355518>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/mkdocs/
...
@alexandrem this solution doesn't work anymore because line 209 is empty - any other idea??
(commented on Jul 2, 2014)I just add a True to the condition on line 209 of the adapter.py to always create a ProxyManager instance, thus skipping the pool manager logic.

Python 3.5.3
pip 9.0.1
Thanks.

@sagar-m

This comment has been minimized.

Copy link

sagar-m commented Jul 11, 2017

Hi, I am not able to install lightgbm in spyder. I get the followinf error...would appreciate any help on how to fix this. Yes, there is a proxy at work. Thanks..!

Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002B1188BDB38>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed',)': /simple/lightgbm/

@jhermann

This comment has been minimized.

Copy link

jhermann commented Jul 11, 2017

Well, seems you got DNS trouble, which pip cannot do anything about. Also, try to avoid appending to closed tickets, that always makes things intransparent.

@SenaniDananjali

This comment has been minimized.

Copy link

SenaniDananjali commented Jul 20, 2017

pip install -U requirement --proxy=my_proxy:port

it worked!!

@sagar-m

This comment has been minimized.

Copy link

sagar-m commented Jul 20, 2017

Hi Senani, did not work for me. Did I code correctly? Let's say I need to download implicit modile.

pip install implicit --proxy=sm_proxy:xx28

Also I am behind a pacs firewall. Each time to use internet, I need to enter logina and password.

Thanks a ton.

@nikordaris

This comment has been minimized.

Copy link

nikordaris commented Sep 14, 2017

So I had a similar issue to this where it was only failing on pip installs from git repo. This only failed when i was behind a proxy. I was not able to get it resolved for git installs over http. I ended up changing my install to use ssh which worked for my environment.

Works behind proxy

pip install git+ssh://git@github.com/path/to/repo@tag#egg=package-name

Doesn't work behind proxy

pip install git+git://github.com/path/to/repo@tag#egg=package-name

@ravibeli

This comment has been minimized.

Copy link

ravibeli commented Sep 26, 2017

Below pip command worked for me.

sudo pip --proxy http://proxy_username:proxy_password@proxyhost:port install <package_to_be_install>

@zored

This comment has been minimized.

Copy link

zored commented Oct 3, 2017

In my case problem was with PIP_INDEX_URL variable.
--isolated helped.

@jangirrishabh

This comment has been minimized.

Copy link

jangirrishabh commented Oct 22, 2017

the --isolated flag worked for me when i'm not behind a proxy but the Cannot connect to Proxy error keeps coming up!

@3tallah

This comment has been minimized.

Copy link

3tallah commented Jan 8, 2018

Just try the below
pip install --proxy=user:pass@server:port <package Name>

for example
pip install --proxy=http://10.10.10.150/accelerated_pac_base.pac quandl

@xliiv

This comment has been minimized.

Copy link

xliiv commented Jun 15, 2018

In my case both solutions work:

  • set proxy in pip pip install --proxy=user:pass@server:port <package Name>
  • or setting HTTP_PROXY & HTTPS_PROXY then pip install <package Name>
@amenaria

This comment has been minimized.

Copy link

amenaria commented Oct 5, 2018

In my case both solutions work:

  • set proxy in pip pip install --proxy=user:pass@server:port <package Name>
  • or setting HTTP_PROXY & HTTPS_PROXY then pip install <package Name>

I already had http_proxy and https_proxy set, but was getting connection failures. Simply setting up HTTP_PROXY and HTTPS_PROXY worked for me.

@scott-rs21

This comment has been minimized.

Copy link

scott-rs21 commented Oct 17, 2018

I was able to resolve the issue by increasing resources on my proxy server. Initially, my proxy server was running 2 "servers" and allowed 5 "client" connections. After increasing to 10 servers and 20 client connections, pip installed packages perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment