python pip安装使用wheel文件无法正常工作

问题描述 投票:2回答:2

由于网络限制和证书错误,我无法正常使用pip安装python库。

所以我尝试下载.whl并手动安装库。但是它也失败了同样的错误。

C:\python3.7>python -m pip install requests-2.21.0-py2.py3-none-any.whl
Processing c:\python3.7\requests-2.21.0-py2.py3-none-any.whl
Collecting idna<2.9,>=2.5 (from requests==2.21.0)
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x039C3D90>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/idna/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04567350>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/idna/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04567D10>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/idna/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04567FD0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/idna/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04545F70>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/idna/
  Could not find a version that satisfies the requirement idna<2.9,>=2.5 (from requests==2.21.0) (from versions: )
No matching distribution found for idna<2.9,>=2.5 (from requests==2.21.0)

按照建议尝试了--use-wheel选项,但不起作用。看起来pip很旧,但是我甚至无法升级pip因为它还需要一个合适的工作网。这是一个捕获22的情况。

C:\python3.7>python -m pip install --use-wheel requests-2.21.0-py2.py3-none-any.whl

Usage:
  C:\python3.7\python.exe -m pip install [options] <requirement specifier> [package-index-options] ...
  C:\python3.7\python.exe -m pip install [options] -r <requirements file> [package-index-options] ...
  C:\python3.7\python.exe -m pip install [options] [-e] <vcs project url> ...
  C:\python3.7\python.exe -m pip install [options] [-e] <local project path> ...
  C:\python3.7\python.exe -m pip install [options] <archive url/path> ...

no such option: --use-wheel

如何手动安装库?

python pip
2个回答
2
投票

问题不在于你的车轮,这是有效的。但这条线很重要:

没有找到idna <2.9,> = 2.5的匹配分布(来自请求== 2.21.0)

所以你需要下载idna。可能还有其他依赖项。

$ python -m pip show requests
Requires: urllib3, chardet, idna, certifi

所以你也需要那四个。说实话,我认为你手动完成这一切会遇到很多困难。依赖关系树可能有几个层次。


2
投票

在有pip工作的机器上,发出:

$ mkdir wheelhouse
$ pip download --dest wheelhouse requests

这将下载requests及其所有依赖项到wheelhouse目录。现在将目录移动到目标机器,出现问题

$ pip install requests --no-index --find-links wheelhouse/

这将告诉pip不要在线搜索包,而是在wheelhouse目录中查找它们(“离线”安装)。

© www.soinside.com 2019 - 2024. All rights reserved.