Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)> in Python?

I have a Django web app that used to work when I had Python installed with Conda. I have recently uninstalled Conda and installed all my Python packages regularly. I'm trying to run my Django app on a local server and it no longer works. I've discovered the problem is this error:

URLError at /submit/
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>
Request Method: POST
Request URL:    http://127.0.0.1:8000/submit/
Django Version: 2.1.1
Exception Type: URLError
Exception Value:    
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>
Exception Location:  /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py in do_open, line 1320
Python Executable:  /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Python Version: 3.6.5

I understand there have been some updates regarding certificates with Python 3.6 (see bottom of this article). I am hoping to find a simple fix to allow me to continue running this Django app on a local host, and I'm hoping to continue using Python 3.6 without Conda. I could try using a virtualenv with a different version of Python installed but I'd like to know if I can still use 3.6. Any insights are appreciated!

like image 242
tiggerae Avatar asked Sep 03 '25 15:09

tiggerae


1 Answers

The second solution in this post solved it for me.

I tried pip install --upgrade certifi, but this didn't solve it. Running the /Applications/Python 3.6/Install Certificates.command script, which itself ran pip install --upgrade certifi, as well as a few other things, worked!

like image 116
tiggerae Avatar answered Sep 05 '25 14:09

tiggerae