【问题标题】:Unable to pip install packages when I am in a virtualenv当我在 virtualenv 中时无法 pip 安装包
【发布时间】:2016-11-21 15:19:17
【问题描述】:

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

当我在 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 中时,我可以 pip 安装包就好了。我已经阅读了很多关于类似错误的 SO 问题,但没有一个与我的情况非常匹配。

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

如果您能指出正确的方向,我将不胜感激

【问题讨论】:

    标签: python windows pip virtualenv


    【解决方案1】:

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

    当我的 repo 在我的 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
    ...
    

    【讨论】:

      猜你喜欢
      • 2017-07-27
      • 2015-07-25
      • 2019-11-28
      • 1970-01-01
      • 1970-01-01
      • 2015-09-28
      • 2016-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多