SSL: CERTIFICATE_VERIFY_FAILED with Python3 SSL: CERTIFICATE_VERIFY_FAILED with Python3 python-3.x python-3.x

SSL: CERTIFICATE_VERIFY_FAILED with Python3


In my case, I used the ssl module to "workaround" the certification like so:

import sslssl._create_default_https_context = ssl._create_unverified_context

Then to read your link content, you can use:

urllib.request.urlopen(urllink)


Go to the folder where Python is installed, e.g., in my case (Mac OS) it is installed in the Applications folder with the folder name 'Python 3.6'. Now double click on 'Install Certificates.command'. You will no longer face this error.

For those not running a mac, or having a different setup and can't find this file, the file merely runs:

pip install --upgrade certifi

Hope that helps someone :)


On Debian 9 I had to:

$ sudo update-ca-certificates --fresh$ export SSL_CERT_DIR=/etc/ssl/certs

I'm not sure why, but this enviroment variable was never set.