【问题标题】:python Pip install using wheel file not workingpython Pip安装使用轮文件不起作用
【发布时间】:2019-01-29 08:35:25
【问题描述】:

由于网络限制和证书错误,我无法正常使用 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,因为这也需要一个适当的工作网络。这是一个 catch22 的情况。

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


    【解决方案1】:

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

    找不到与 idna=2.5 匹配的分布(来自 requests==2.21.0)

    因此您还需要下载idna。可能还有其他依赖项。

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

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

    【讨论】:

    • 哦 :( 太麻烦了,有没有办法下载该软件包所需的所有轮子。
    • python -m pip shows requests 显示空白输出
    • 是的,我也注意到了这一点。 show 仅在安装了模块后才有效。您在这里尝试过这种方法吗?为避免证书问题:stackoverflow.com/a/29751768/1291498
    • 是的,请参阅我的另一个问题。 stackoverflow.com/questions/54406115/… 我为此感到非常沮丧,我的公司 IT 很糟糕。我认为我无法向他们解释特定问题,我需要尽快开发此 POC
    • Auch :( 我感到你很沮丧。害怕没有其他方法,然后手动尝试找出依赖项并下载它们。从最低的依赖项开始。好消息是,从我能做到的看;对于requests,你只需要我提到的那四个。它们没有进一步的依赖关系!但我猜请求不是你唯一的要求..
    【解决方案2】:

    在运行pip的机器上,问题:

    $ mkdir wheelhouse
    $ pip download --dest wheelhouse requests
    

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

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

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

    【讨论】:

    • 好的,我可以在驾驶室一次获得所有或大部分包裹吗?否则我将不得不一次又一次地下载、移动、安装
    • pip download 将一次性下载软件包及其所有依赖项,只要您不告诉它与 --no-deps 做相反的事情。另外,请查看我在您的其他问题中的评论以及命令建议。
    • 就像所有的包集合一样,即使是 GB 的大小
    • 不,只有安装requests所需的每个包;四个或五个。
    猜你喜欢
    • 2014-08-29
    • 2020-12-11
    • 2021-04-28
    相关资源
    最近更新 更多