Unable to pip install packages when I am in a virtualenv

Question:

I’m hoping SO will be able to help with this problem.

I am unable to pip install any packages when I am in a virtualenv. I’m on Windows 7, and python 2.7.12.

For example, when I use git bash like this:

(venv2)
me@myhost ~/git/myrepo (master)
$ pip install requests

I get the following error:

Collecting requests
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x02A438F0>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed',)': /simple/requests/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x02A43790>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed',)': /simple/requests/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x02A43B50>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed',)': /simple/requests/
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x02A43DD0>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed',)': /simple/requests/
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x02A43E50>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed',)': /simple/requests/
Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests

However, when I am not in a virtualenv, I can pip install packages just fine. I’ve read quite a lot of SO questions about similar errors, but none match my case very well.

Some things I tried: uninstalling and reinstalling python; upgrading pip; switching python versions.

If you can point me in the right direction, I’d greatly appreciate it

Asked By: user5012123

||

Answers:

Old question, but I just had a very similar problem and there was no answer posted.

When my repo was on my G: drive, and python install was on C:. Moving the repo to the C: drive solved my issue and I was able to use pip to install my venv requirements.txt.

on G:

(env) G:repo>pip install -r requirements.txt
Collecting flask>=0.11 (from -r requirements.txt (line 1))
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connec
tion broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.conne
ction.VerifiedHTTPSConnection object at 0x0000000004393E10>: Failed to establish
 a new connection: [Errno 11003] getaddrinfo failed',)': /simple/flask/
  Retrying (Retry(total=3, ...

  Could not find a version that satisfies the requirement flask>=0.11 (from -r r
equirements.txt (line 1)) (from versions: )
No matching distribution found for flask>=0.11 (from -r requirements.txt (line 1
))

on C:

(env) C:repo>pip install -r requirements.txt
Collecting flask>=0.11 (from -r requirements.txt (line 1))
  Using cached Flask-0.12-py2.py3-none-any.whl
...
Answered By: John Robinson

netsh interface ipv4 set subinterface "Wi-Fi" mtu=1472 store=persistent

try running above cmd. It might help.
Some times the problem while installing the packages might be with your firewall or with the network provider
so we store it as persistent.

Answered By: Yuvraj Darekar

I have also encountered such a problem. I fought with her for two days. When you run the package installation command in a virtual environment, for example pip install pandas, then you are in the scripts directory and the file is located here pip.exe and so it starts. And it is most likely a version newer or different than pip, which is called when running from the command line. When you run pip install pandas on the command line , c is called:anaconda3scriptspip.exe and this team is working. And the command that is called in the virtual environment does not work, since the version pip.exe the other one. I have pip.exe there were versions 9.0 and 19.0 . I solved the problem simply – I started running c:anaconda3scriptspip install pandas directly in the pycharm console in a virtual environment

Answered By: Anatolii Chimbeev
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.