Easy_install 或 pip 安装错误:[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:579)]

Posted

技术标签:

【中文标题】Easy_install 或 pip 安装错误:[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:579)]【英文标题】:Easy_install or pip install error : [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)] 【发布时间】:2018-12-12 22:52:28 【问题描述】:

在我的 centos 服务器上,每当尝试安装新软件包时,我突然收到 SSL 验证失败消息。

有人可以帮我解决这个问题吗?

在新机器上:

easy_install-2.7 pip Searching for pip Reading https://pypi.python.org/simple/pip/ Best match: pip 10.0.1 Downloading https://files.pythonhosted.org/packages/ae/e8/2340d46ecadb1692a1e455f13f75e596d4eab3d11a57446f08259dee8f02/pip-10.0.1.tar.gz#sha256=f2bd08e0cd1b06e10218feaf6fef299f473ba706582eb3bd9d52203fdbd7ee68 error: Download error for https://files.pythonhosted.org/packages/ae/e8/2340d46ecadb1692a1e455f13f75e596d4eab3d11a57446f08259dee8f02/pip-10.0.1.tar.gz#sha256=f2bd08e0cd1b06e10218feaf6fef299f473ba706582eb3bd9d52203fdbd7ee68: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)

我之前使用 pip 安装了许多 python 模块的现有服务器,但现在我收到 ssl 验证错误

# pip install certifi Collecting certifi   Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)'),)': /packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)'),)': /packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)'),)': /packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)'),)': /packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)'),)': /packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl

Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)'),))

【问题讨论】:

【参考方案1】:

此错误是由尚未排序的https://github.com/pypa/setuptools/issues/1543 引起的。

我知道的唯一解决方法是避免使用代理,或者至少使用不会重写 SSL 证书的代理。

不要忘记对该问题发表评论,以确认它也会影响您。

【讨论】:

以上是关于Easy_install 或 pip 安装错误:[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:579)]的主要内容,如果未能解决你的问题,请参考以下文章

pip安装Python包出现错误,easy_install可以安装

python windows 下pip easy_install 使用错误的问题

使用 pip、easy_install、manual 安装 PyObjc 时遇到问题

python 安装easy_install和pip

Python之pip安装注意事项及解决办法

Python 安装包setuptools easy_install pip