如何使用Python 2.7修复Windows上的pip安装证书问题? [英] How can I fix pip install certificate issue on Windows with Python 2.7?

查看:249
本文介绍了如何使用Python 2.7修复Windows上的pip安装证书问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows中,我安装了Python 2.7.我在虚拟环境中使用此版本的Python.当我尝试使用任何东西进行pip安装时,都会出现以下错误,指出我没有有效的安全证书.

In Windows, I have Python 2.7 installed. I am using this version of Python in my virtual environment. When I try pip install with anything I get the following kinds of errors stating that I do not have a valid security certificate.

c:\ projects \ scrubbed \ scrubbed \ env \ lib \ site-packages \ pip_vendor \ urllib3 \ util \ ssl_.py:339: SNIMissingWarning:已发出HTTPS请求,但SNI TLS(主题名称指示)扩展名在此上不可用 平台.这可能导致服务器显示不正确的TLS 证书,这可能会导致验证失败.您可以升级到 较新版本的Python即可解决此问题.有关更多信息,请参见 https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings SNISSISSING警告 c:\ projects \ scrubbed \ scrubbed \ env \ lib \ site-packages \ pip_vendor \ urllib3 \ util \ ssl_.py:137: InsecurePlatformWarning:真正的SSLContext对象不可用. 这会阻止urllib3正确配置SSL并可能导致 某些SSL连接失败.您可以升级到更高版本的 Python解决了这个问题.有关更多信息,请参见 https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecurePlatformWarning重试(Retry(total = 4,connect = None, 连接断开后,读取=无,重定向=无,状态=无)) 'SSLError(SSLError(1,'_ssl.c:499:error:1407742E:SSL 例程:SSL23_GET_SERVER_HELLO:tlsv1警报协议版本'),)': /简单/证明/ c:\ projects \ scrubbed \ scrubbed \ env \ lib \ site-packages \ pip_vendor \ urllib3 \ util \ ssl_.py:137: InsecurePlatformWarning:真正的SSLContext对象不可用. 这会阻止urllib3正确配置SSL并可能导致 某些SSL连接失败.您可以升级到更高版本的 Python解决了这个问题.有关更多信息,请参见 https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

c:\projects\scrubbed\scrubbed\env\lib\site-packages\pip_vendor\urllib3\util\ssl_.py:339: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings SNIMissingWarning c:\projects\scrubbed\scrubbed\env\lib\site-packages\pip_vendor\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecurePlatformWarning Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/certifi/ c:\projects\scrubbed\scrubbed\env\lib\site-packages\pip_vendor\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

我在Python 3.6.5虚拟环境中没有这些问题.不幸的是,我需要使用Python 2.7进行Google App Engine开发.

I don't have these problems with a Python 3.6.5 virtual environment. Unfortunately, I need to use Python 2.7 for Google App Engine development.

我的requirements.txt文件包括以下内容:

My requirements.txt file includes the following:

Flask>=0.12
Flask-Cors>=3.0.3
flask-restplus>=0.10.1
google-api-python-client>=1.6.5
GoogleAppEngineCloudStorageClient>=1.9.22.1

我现在对任何修复都感兴趣.我已经尝试了在StackOverflow上找到的所有内容.

I am interested in any fixes at this point. I have tried just about everything I have found on StackOverflow.

修改 已将其标识为问题的可能重复项,"...找不到满足要求的版本..." .但是,这些错误消息是完全不同的.我的实际修复方法是完全安装从 Python.org>下载的Python 2.7.14

Edit This is has been identified as a possible duplication of the question, "...Could not find a version that satisfies the requirement...". These error messages were however quite different. My actual fix was to completely install Python 2.7.14, downloaded from Python.org

推荐答案

在您的错误中看到以下行:

See this line in your error:

routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': 

Python.org网站最近已停止了对TLS v1.0和v1.1的支持

Python.org sites have recently stopped support for TLS v1.0 and v1.1

尝试如下升级点子:

curl https://bootstrap.pypa.io/get-pip.py | python

升级pip后,您仍然可以使用Python 2.7,因为它将使用更高的TLS版本(即> = 1.2)

You can still use Python 2.7 once you upgrade pip since it will then use the later TLS version (i.e >=1.2)

有关更多详细信息,请参见此答案.

See this answer for more details.

这篇关于如何使用Python 2.7修复Windows上的pip安装证书问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆