In this post , we will see How To Fix - "Ssl: Certificate_Verify_Failed” Error” Error in Python . Sometimes while trying to access a specific web-page through a python script , it generates the following error
URLError: <urlopen error \[SSL: CERTIFICATE\_VERIFY\_FAILED\] certificate verify failed
Let us see the various options we have to fix the above issue.
$ sudo update-ca-certificates --fresh
$ export SSL\_CERT\_DIR=/etc/ssl/certs
./Install Certificates.command
If you are unable to find the "certifi", then use below set of commands to proceed ahead with the SSL error issue fix -
pip install certifi
/YOUR\_PYTHON\_INSTALLED\_LOCATION/Python/3.6/Install/ Certificates.command
import ssl
context = ssl.\_create\_unverified\_context()
urllib.urlopen("https://URL\_LINK", context=context)
or
import ssl
ssl.\_create\_default\_https\_context = ssl.\_create\_unverified\_context
Hope this solves the issue. Additional Read -