由于网络限制和证书错误,我无法正常使用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
选项,但不起作用。点子看起来很旧,但是我什至不能升级点子,因为那还需要一个合适的工作网。这是一个问题。
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
如何手动安装库?
答案 0 :(得分:2)
问题不在于您要解决的问题。但是这一行很重要:
找不到IDna <2.9,> = 2.5的匹配分布(来自请求== 2.21.0)
因此,您还需要下载idna
。可能还有其他依赖性。
$ python -m pip show requests
Requires: urllib3, chardet, idna, certifi
所以您同样需要这四个。老实说,我想您将很难手动完成所有这些工作。依赖关系树可能有几个层次。
答案 1 :(得分:2)
在运行pip
的计算机上,发出:
$ mkdir wheelhouse
$ pip download --dest wheelhouse requests
这会将requests
及其所有依赖项下载到wheelhouse
目录。现在将目录移动到目标计算机,出现问题
$ pip install requests --no-index --find-links wheelhouse/
这将告诉pip
不要在线搜索软件包,而要在wheelhouse
目录中寻找它们(“离线”安装)。