Mac OSX python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)
Many operations in python require accessing things via https. This includes pip install, or just using http.client.HTTPSConnection, or any modules or applications that use these things internally.
If python was installed from the official python pkg installer, downloaded from https://python.org, then it uses an internal version of openssl, and contains no root certificates. Anything that uses an SSL connection results in this error:
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)
How can I install root certs to make the above error go away?
Solution 1:
When you run the python installer, they display this information to you. It is also documented in /Applications/Python 3.6/ReadMe.rtf
, but it's very easily overlooked.
Just browse to Applications/Python 3.6
and double-click Install Certificates.command
There is an issue in the Python bug tracker about this. http://bugs.python.org/issue29480
Update: This issue is marked as resolved in the bug tracker with this text being part of the latest comment:
... 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. ...
Solution 2:
I solved this problem using this command:
open /Applications/Python\ 3.7/Install\ Certificates.command
I have Python 3.7 in my machine.
Check this link - Fixing CERTIFICATE_VERIFY_FAILED error when trying requests-html out on Mac