Skip to content
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 · 86 comments
Closed
Labels
auto-locked Outdated issues that have been locked by automation C: proxy Dealing with proxies and networking

Comments

@shredder12
Copy link

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
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
Copy link
Author

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
Copy link
Member

dstufft commented May 8, 2014

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

@shredder12
Copy link
Author

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
Copy link

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
Copy link
Author

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

@Ivoz
Copy link
Contributor

Ivoz commented Jun 12, 2014

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

@pcraston
Copy link

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
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
Copy link

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
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
Copy link

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

@shredder12
Copy link
Author

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
Copy link

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

@dstufft
Copy link
Member

dstufft commented Jun 24, 2014

This appears to be a requests bug, I've redirected this to upstream here: https://github.com/kennethreitz/requests/issues/2110

@dstufft
Copy link
Member

dstufft commented Jun 24, 2014

Or perhaps urllib3.

@dstufft
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
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
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
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
Copy link

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
Copy link
Author

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
Copy link

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
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
Copy link

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
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
Copy link

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

@alexandrem
Copy link

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
Copy link
Member

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.

@mandshaw
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
Copy link

@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
Copy link

@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
Copy link

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

@xavfernandez xavfernandez added the C: proxy Dealing with proxies and networking label Apr 3, 2016
@ashi-taka
Copy link

@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
Copy link

@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
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
Copy link

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

@genesem
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
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
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
Copy link

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
Copy link

SenaniDananjali commented Jul 20, 2017

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

it worked!!

@sagar-m
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
Copy link

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
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
Copy link

zored commented Oct 3, 2017

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

@jangirrishabh
Copy link

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

@3tallah
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

@ghost
Copy link

ghost 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
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
Copy link

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.

@lock
Copy link

lock bot commented May 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 31, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: proxy Dealing with proxies and networking
Projects
None yet
Development

No branches or pull requests