python 中的许多操作都需要通过 https 访问。这包括 pip install,或仅使用 http.client.HTTPSConnection,或在内部使用这些东西的任何模块或应用程序。
如果python是从官方python pkg安装程序安装的,从https://python.org下载,然后它使用 openssl 的内部版本,并且不包含根证书。任何使用 SSL 连接都会导致此错误:
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)
如何安装根证书以消除上述错误?
最佳答案
当您运行 python 安装程序时,它们会向您显示此信息。它也记录在 /Applications/Python 3.6/ReadMe.rtf
中,但很容易被忽略。
只需浏览到 Applications/Python 3.6
并双击 Install Certificates.command
Python 错误跟踪器中有一个关于此的问题。 http://bugs.python.org/issue29480
更新:此问题在错误跟踪器中标记为已解决,此文本是最新评论的一部分:
... For 3.7.0b2, I have tried to make things more obvious in two ways. One, the installer package will now attempt to open a Finder window for the /Application/Python 3.7 folder that contains the "Install Certificates.command". Two, rather than just a generic "installation complete" message at the end of the install, there is now a tailored message that urges the user to click on the "Install Certificates.command" icon. ...
关于python - Mac OSX python ssl.SSLError : [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl. c:749),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42098126/