Skip to content

Instantly share code, notes, and snippets.

@davedavis
Created November 8, 2020 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davedavis/407abbd3800c6d31771b8ac93f9bc2fe to your computer and use it in GitHub Desktop.
Save davedavis/407abbd3800c6d31771b8ac93f9bc2fe to your computer and use it in GitHub Desktop.
How to fix Python urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)>
OK, after a lot of heartache, I've solve this. As usual, the solution was painfully simple.
Certifi uses it's own bundled certificate bundle, so you can use the one from here: https://curl.haxx.se/ca/cacert.pem
Basically, download it (or use your own from the certifi dist directory)
Then, set the env variable (in /etc/envirnoment if you're on Ubuntu like me) for $SSL_CERT_FILE to the one you downloaded:
export SSL_CERT_FILE=/home/yourname/cacert.pem
Worked immediately from main system CLI. I had to uninstall PyCharm and reinstall it for it to pick up the env variable and start working in virtualenvs again.
Sources: https://access.redhat.com/articles/2039753#troubleshooting-certificate-verification-8 and https://stackoverflow.com/users/6451573/jean-fran%c3%a7ois-fabre
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment