python 当我在virtualenv中时无法pip安装软件包

k7fdbhmy  于 2022-12-10  发布在  Python
关注(0)|答案(2)|浏览(203)

我希望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安装包。我读过很多关于类似错误的问题,但没有一个与我的情况非常匹配。
我试过一些事情:卸载并重新安装python;升级PIP;切换Python版本。
如果你能给我指明正确的方向,我将不胜感激

p3rjfoxz

p3rjfoxz1#

老问题,但我只是有一个非常相似的问题,并没有张贴答案。
当我的回购协议在我的G:驱动器,而Python安装在C:上。将存储库移动到C:驱动器解决了我的问题,我能够使用pip安装我的venv requirementsidertxt。
在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
...
cqoc49vn

cqoc49vn2#

netsh接口ipv4设置子接口“Wi-Fi”mtu=1472存储=持久
尝试运行上面的命令。2这可能会有帮助。3有时候安装软件包的问题可能与你的防火墙或网络提供商有关,所以我们将其保存为永久性的。

相关问题