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?
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
There is an issue in the Python bug tracker about this.
Update: This issue is marked as resolved in the bug tracker with this comment being the latest one:
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.
I solved this problem using this command:
open /Applications/Python\ 3.7/Install\ Certificates.command
I have Python 3.7 in my machine.
In my case none of the solutions worked with the system installed python3 in macOS Catalina, neither did it work with python3 installed via brew.
If someone has a situation like this and wants a quick solution,
Download and install python3 again, using https://www.python.org/downloads/
At the end of the installation, the installer would show you a note, asking to run the
Install Certificates.command file.
(With the other installations, this file was not present, and neither was the solution with the file’s source code working)
Restart the terminal, and you can type
where python3, to see
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3. Using this binary, the problem should not occur.
Note: It might be possible to make the system-installed python3 work, but in my case; it proved to be extremely hard, so I choose this way.
Cool way to solve this issue for all your python version and without checking your version on macOS
bash /Applications/Python*/Install\ Certificates.command
This command is equivalent to:
... bash /Applications/Python\ 2.7/Install\ Certificates.command bash /Applications/Python\ 3.6/Install\ Certificates.command bash /Applications/Python\ 3.7/Install\ Certificates.command ...
It helped me hope it will help you as well
A cheap way around this is just using python3.5 if you still have it installed.
Pushing to PyPI:
python3.5 setup.py register -r pypitest
python3.5 setup.py sdist upload -r pypitest
pipping seems to work fine with 3.6 out of the box..
I faced the same problem, when I tried to run Python with Keras data loading. The error for me was:
Exception: URL fetch failure on AWS_URL: None -- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
I fixed my problem by upgrading the certificate as:
pip install --upgrade certifi
If you’re using macOS open finder and go to Applications > Python3.7 folder (or whatever version of python you’re using) > double click on “Install Certificates.command” file.