当我在virtualenv

时间:2016-11-21 15:19:18

标签: python windows pip virtualenv

我希望能够帮助解决这个问题。

当我在virtualenv中时,我无法pip安装任何软件包。我在Windows 7和python 2.7.12上。

例如,当我像这样使用git bash时:

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

我收到以下错误:

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

然而,当我不在virtualenv中时,我可以很好地使用安装包。我已经阅读了很多关于类似错误的SO问题,但没有一个与我的情况相符。

我试过的一些事情:卸载并重新安装python;升级点;切换python版本。

如果你能指出我正确的方向,我会非常感激

1 个答案:

答案 0 :(得分:1)

老问题,但我遇到了一个非常类似的问题,并且没有发布答案。

当我的回购邮件在我的G:驱动器上时,python安装在C:上。将repo移动到C:驱动器解决了我的问题,我能够使用pip来安装我的venv requirements.txt。

在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
))

在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
...