I'm in an enterprise setup, but I'm not behind a proxy.
I'm using git bash.
Description
I can't install modules with pip when I'm inside a virtual enviroment. I can install modules with pip, when I'm not inside a virtual enviroment.
The error I'm getting is: "Failed to establish a new connection: [Errno 11003] getaddrinfo failed')': /simple/modulename"
Example of installing/updating pip with trusted hosts enabled outside the virtual enviroment
$ python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip
Requirement already up-to-date: pip in c:\users\penyme\appdata\local\programs\python\python37\lib\site-packages (10.0.1)
Example of the same operation within a virtual enviroment:
$ source env/Scripts/activate
x@x MINGW64 /p/Workspace/_poc/DjangoTango/DjangoTango
(env)
$ python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002ABE4C84978>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed')': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002ABE4ABE128>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed')': /simple/pip/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002ABE4C4B2E8>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed')': /simple/pip/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002ABE4C76AC8>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed')': /simple/pip/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002ABE4C76B70>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed')': /simple/pip/
Requirement already up-to-date: pip in p:\workspace\_poc\djangotango\djangotango\env\lib\site-packages (10.0.1)
Pip is up-to-date, but when I try to install Djnago it looks like this:
$ pip install "django<1.12"
Collecting django<1.12
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000001B8DB4D22B0>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed')': /simple/django/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000001B8DB4C7F60>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed')': /simple/django/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000001B8DB4C7EB8>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed')': /simple/django/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000001B8DB4C7E48>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed')': /simple/django/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000001B8DB4C7D68>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed')': /simple/django/
Could not find a version that satisfies the requirement django<1.12 (from versions: )
No matching distribution found for django<1.12
if I try the same command on my base enviroment it looks like:
$ pip install "django<1.12"
Collecting django<1.12
Downloading https://files.pythonhosted.org/packages/bf/e0/e659df5b5b82299fffd8b3df2910c99351b9308b8f45f5702cc4cdf946e9/Django-1.11.14-py2.py3-none-any.whl (7.0MB)
Collecting pytz (from django<1.12)
Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)
Installing collected packages: pytz, django
Successfully installed django-1.11.14 pytz-2018.5
Something seems indeed to be broken inside your virtual environment.
Does python -c "import socket;print(socket.getaddrinfo('pypi.org', 443))"
work inside it ?
@xavfernandez beat me to it. :)
As an aside, putting pip's output in a code block (by surrounding it with ```
above and below) would make it easier to read. :)
@xavfernandez
Doesn't seem like it. This is from the virtual enviroment:
$ python -c "import socket;print(socket.getaddrinfo('pypi.org', 443))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\x\AppData\Local\Programs\Python\Python37\lib\socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11003] getaddrinfo failed
This is from outside:
$ python -c "import socket;print(socket.getaddrinfo('pypi.org', 443))"
[(<AddressFamily.AF_INET: 2>, 0, 0, '', ('151.101.128.223', 443)), (<AddressFamily.AF_INET: 2>, 0, 0, '', ('151.101.0.223', 443)), (<AddressFamily.AF_INET: 2>, 0, 0, '', ('151.101.192.223', 443)), (<AddressFamily.AF_INET: 2>, 0, 0, '', ('151.101.64.223', 443))]
It's not just tied to this virtualenviroment, but is the same for all of them.
@Sidstling you apparently have an issue with the python used inside your venvs.
Is it the same as the global one ?
@xavfernandez
I'm not sure how to check exactly, but it seems like the fact that I'm operating on a network drive while having python installed on my c drive is what is breaking the venv, because when I just tried to make a venv on a temp folder on my cdrive I got:
$ source envtest/Scripts/activate
(envtest)
x@x MINGW64 /c/work
$ python -c "import socket;print(socket.getaddrinfo('pypi.org', 443))"
[(<AddressFamily.AF_INET: 2>, 0, 0, '', ('151.101.192.223', 443)), (<AddressFamily.AF_INET: 2>, 0, 0, '', ('151.101.128.223', 443)), (<AddressFamily.AF_INET: 2>, 0, 0, '', ('151.101.0.223', 443)), (<AddressFamily.AF_INET: 2>, 0, 0, '', ('151.101.64.223', 443))]
Modules also download and install.
@Sidstling is your issue fixed? If so, it'd be helpful for someone else who might be facing this issue if you could mention how you resolved it. :)
@pradyunsg it鈥檚 not fixed exactly, but the issue is with how venvs are created on network drives and not what I originally described.
I avoid the issue by not using the network drive to create my venvs.
I received the same error when I ran from a network drive (H:) vs a local (C:) drive. Python 3.6
H:\data\python\opstree>opstree_env\Scripts\activate.bat
(opstree_env) H:\data\python\opstree>pip install -r redis-load-test\Scripts\requirments.txt
Collecting locust (from -r redis-load-test\Scripts\requirments.txt (line 1))
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('
Most helpful comment
@pradyunsg it鈥檚 not fixed exactly, but the issue is with how venvs are created on network drives and not what I originally described.
I avoid the issue by not using the network drive to create my venvs.