【问题标题】:Cannot install any package using pip无法使用 pip 安装任何软件包
【发布时间】:2019-02-21 10:40:15
【问题描述】:

每当我尝试通过 pip install <package> 从我的 Amazon EC2 实例安装软件包时,都会遇到以下问题:

pip install opencv-python
Collecting opencv-python
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('rsa routines', 'INT_RSA_VERIFY', 'bad signature'), ('asn1 encoding routines', 'ASN1_item_verify', 'EVP lib'), ('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /simple/opencv-python/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('rsa routines', 'INT_RSA_VERIFY', 'bad signature'), ('asn1 encoding routines', 'ASN1_item_verify', 'EVP lib'), ('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /simple/opencv-python/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('rsa routines', 'INT_RSA_VERIFY', 'bad signature'), ('asn1 encoding routines', 'ASN1_item_verify', 'EVP lib'), ('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /simple/opencv-python/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('rsa routines', 'INT_RSA_VERIFY', 'bad signature'), ('asn1 encoding routines', 'ASN1_item_verify', 'EVP lib'), ('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /simple/opencv-python/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('rsa routines', 'INT_RSA_VERIFY', 'bad signature'), ('asn1 encoding routines', 'ASN1_item_verify', 'EVP lib'), ('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /simple/opencv-python/
  Could not fetch URL https://pypi.org/simple/opencv-python/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/opencv-python/ (Caused by SSLError(SSLError("bad handshake: Error([('rsa routines', 'INT_RSA_VERIFY', 'bad signature'), ('asn1 encoding routines', 'ASN1_item_verify', 'EVP lib'), ('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)) - skipping
  Could not find a version that satisfies the requirement opencv-python (from versions: )
No matching distribution found for opencv-python

在上面的示例中,包opencv-python 可在https://pypi.org/project/opencv-python/ 获得。我正在使用 Anaconda 环境中的 Python 3.6。

此外,使用conda install <package> 会导致同样的错误:

conda search numpy
Loading channels: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/free/noarch/repodata.json.bz2>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/free/noarch/repodata.json.bz2 (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'tls_process_key_exchange\', \'bad signature\')],)",),))',),)

不知道是网络接口的问题还是Python环境的问题?我已经尝试了所有找到的解决方案,但没有任何效果。

【问题讨论】:

  • 你能连接到任何网络资源吗?
  • 是的,我尝试了wget 一个图像,它有效。
  • https 资源呢?
  • pip install 为我工作。目前正在下载 39.7 mb 的 opencv-python 4.0.0.21。
  • @Yossi wget 不适用于https,可能是网络设置,谢谢。

标签: python python-3.x pip anaconda


【解决方案1】:

请确认您的实例的安全组允许出站流量到端口 443

【讨论】:

    【解决方案2】:

    我相信,如果您查看了您的 VPC 设置,您会发现您正在使用网络 ACLS 阻止外部 IP 地址。通常,这些用于控制 VPC 中子网之间的流量。

    这是 Amazon EC2 上的常见错误。

    检查您的设置将解决问题!

    问候, ??

    附:您的 Python 环境运行良好!

    【讨论】:

    • 可能是的,因为 wget 不适用于 https 资源。我会检查并确认
    【解决方案3】:

    尝试在 Windows 10 中使用Network Reset 选项

    • 选项
    • 网络和互联网
    • 状态选项卡
    • 查看页尾(网络重置)
    • 立即重置

    它会删除所有已保存的 WI-FI 密码

    【讨论】:

      【解决方案4】:

      这是一个特定于 Windows 的答案,适用于面临与问题中描述的相同问题但在 Windows 计算机上的任何人。到目前为止,StackOverflow 上的 Windows 操作系统还没有解决此问题的答案。

      经过几天的搜索,我找到了这个!

      第 1 步:按 Win+R 打开“运行”,输入“regedit”并单击“确定”。
      第 2 步:移至 HKEY_CURRENT_USER/软件/Microsoft/Windows/当前版本/Internet 设置。
      第 3 步:找到一个名为“ProxyServer”的文件并将其删除。
      第 4 步:打开 cmd
      第 5 步:触发命令“pip install flask-bcrypt”

      致谢:https://github.com/pypa/pip/issues/7424

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-04-21
        相关资源
        最近更新 更多