代码之家  ›  专栏  ›  技术社区  ›  JackTheKnife

Python PIP和unsecureplatformwarning

  •  2
  • JackTheKnife  · 技术社区  · 6 年前

    我正在尝试安装 requests

    sudo pip install requests[security]
    

    我收到以下错误消息:

    /usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
      InsecurePlatformWarning
    Collecting requests[security]
    /usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
      InsecurePlatformWarning
    /usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
      InsecurePlatformWarning
    

    我确保所有的系统库都准备好了

    sudo yum install openssl-devel python-devel libffi-devel
    

    那里一切都很好

    所以我试过了

    sudo pip install pyopenssl ndg-httpsclient pyasn1
    

    sudo pip install --trusted-host pypi.python.org requests
    

    这些也失败了。

    你知道这里出了什么问题,怎么解决吗?

    附言

    我决定降级 pip 皮普 版本6.1+。你觉得呢?

    2 回复  |  直到 6 年前
        1
  •  1
  •   stop.climatechange.now    6 年前

    实际上,截至2019年,仍有不少人面临这个问题,因为由于各种限制,他们无法升级系统Python(以及系统提供的openssl)。

    如果你想修好 InsecurePlatformWarning .. (Caused by SSLError .. SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version') ,以下解决方案可以帮助使用旧Linux发行版的用户:

    Unable to install Python packages using pip in Ubuntu Linux: InsecurePlatformWarning, SSLError, tlsv1 alert protocol version

    CentOS6上的Python 2.6.6

    在你的特殊情况下 cryptography 正式支持python2.6的版本是cryptography-2.1.1,不过可能需要更新的版本。 第一个 男性1 加密软件包包括自己的OpenSSL(1.1.0f)Linux共享lib绑定,不管您的平台上有什么,它已经出现在cryptography-2.0版本中。上一次官方支持Centos 6.4的加密是版本1.8.2,而较新版本官方只支持Centos 7.x: https://pypi.org/project/cryptography/#files

    注意,加密版本<2.0没有 manylinux1
    https://cryptography.io/en/latest/installation/#using-your-own-openssl-on-linux
    https://cryptography.io/en/latest/installation/#rhel-centos


    https://cryptography.io/en/latest/installation/#static-wheels

    也就是说,

    如果你只需要安装 requests lib(没有解决臭名昭著的SSLError),特别是在CentOS6上的Python2.6.6中,您不需要TLS1.2协议支持 请求

    $ yum search requests
    $ sudo yum install python26-requests

    请求 above-mentioned solution ,从wheels或tar.gz下载自: https://pypi.org/project/requests/

    注意,最新的 请求 在PyPI上依赖于以下Python包: urllib3、idna、chardet、certifi

    幸运的是,这四个函数没有其他依赖项,可以直接从PyPI中获得,方法相同-函数 PyPI部分:
    https://pypi.org/project/urllib3/
    https://pypi.org/project/idna/
    https://pypi.org/project/chardet/
    https://pypi.org/project/certifi/

    您可以下载并尝试安装它们的最新版本,或者根据您的用例和系统特定的需求,使用“发布历史记录”部分查找旧版本。

    注意,现在很多web服务器(包括PyPI)都需要tls1.2支持,包括客户端和服务器后端,以建立HTTPS连接,因此如果您需要这种类型的连接, 如果不按照上面讨论的方法修复SSLError(或者编译一个更新的python2.7.9+),它将无法工作 OpenSSL 之前 编译新Python,链接 ssl 模块)。

        2
  •  0
  •   Kirito    6 年前

    试试这个:

    sudo pip安装请求