SSL: CERTIFICATE_VERIFY_FAILED error with python3 on macOS 10.15
The problem is that /usr/bin/python3
(from either Xcode or CLT) fails to correctly locate the trust store in /etc/ssl
, as we can see using ssl.get_default_verify_paths()
:
$ /usr/bin/python3 -c 'import ssl; print(ssl.get_default_verify_paths())'
DefaultVerifyPaths(cafile=None, capath=None, openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/etc/ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/etc/ssl/certs')
It's looking into /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/etc/ssl
, which doesn't exist.
Knowing this, we can use the following hack:
$ sudo rsync -avzP /etc/ssl/ /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/etc/ssl/
I've submitted a bug report to Apple (btw, just realized bugreport.apple.com is now gone, and I had to use the Feedback Assistant website). Open radar https://openradar.appspot.com/7111585 (that radar number is unfortunately wrong — since bugreport.apple.com is gone, I don't have a radar number anymore, only a feedback number FB7111585
).
Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for http://en.wikipedia.org
Once upon a time I stumbled with this issue. If you're using macOS go to Macintosh HD > Applications > Python3.6 folder (or whatever version of python you're using) > double click on "Install Certificates.command" file. :D
Related Topics
How to Write Python Array (Data = []) to Excel
How to Center a Window on the Screen in Tkinter
How to Convert Column With String Type to Int Form in Pyspark Data Frame
Pandas - How to Compare 2 CSV Files and Output Changes
Printing Even Characters With Strings in Python
Pythonic Way to Check If Two Dictionaries Have the Identical Set of Keys
Python Pandas: Nameerror: Name Is Not Defined
How to Copy a File to a Remote Server in Python Using Scp or Ssh
How to Check the Date Is Empty Using Python
Django Rest Framework Csrf Failed: Csrf Cookie Not Set
How to Crop the Black Background of the Image Using Opencv in Python
Add Missing Dates to Pandas Dataframe
Create a New Dataframe Based on Rows With a Certain Value
Python - Ensuring a Variable Holds a Positive Number
Permission System for Discord.Py Bot
Using Opencv to Overlay Transparent Image Onto Another Image
How to Append Data Using Openpyxl Python to Excel File from a Specified Row