python3 ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833) Error

File “/Library/Frameworks/ Versions/3.6/lib/python3.6/urllib/request.py” on line 1318, do_open

encode_chunked = req.has_header(transmit encoded))

File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py” on line 1239 in request

self. _send_request(method, url, body, title, encode_chunked)

File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py” on line 1285 in _send_request

ego. endheaders(body,encode_chunked = encode_chunked)

File “/Library/Frameworks/ pythonframework /Versions/3.6/lib/python3.6/http/client.py” on line 1234 in endheaders

self. _send_output (message_body encode_chunked = encode_chunked)

File “/Library/Frameworks/ pythonframework /Versions/3.6/lib/python3.6/http/client.py” on line 1026 in _send_output

self.send(MSG)

File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py” on line 964 in send

self.connect ()

File “/Library/Frameworks/ pythonframework /Versions/3.6/lib/python3.6/http/client.py” on line 1400, in connect

server_hostname = server_hostname)

File “/Library/Frameworks/ Versions/3.6/lib/python3.6/ssl.py”, line 407, in wrap_socket

_context = self,_session = session)

File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py” on line 814 in rest of init__

self.do_handshake ()

File “/Library/Frameworks/ pythonframework /Versions/3.6/lib/python3.6/ssl.py” on line 1068 in do_handshake

self._sslobj.do_handshake ()

File “/Library/Frameworks/ pythonframework /Versions/3.6/lib/python3.6/ssl.py” on line 689 in do_handshake

self._sslobj.do_handshake ()

ssl. certificate validation failure (_ssl.c:833)
python2.7 upgrade to python3 requires ssl checksumming
So you need to introduce the module ssl
Imported ssl
In the urlopen
Context adds ssl._create_unverified_context ()
Just close the ssl check.
url = “https://www.baidu.com” context = ssl._create_unverified_context()get = urllib.request. urlopen(url, context = context).read()
print
However, this approach is not recommended, as it is better not to close the authentication

> from urllib import request
>>> url = 'https://www.baidu.com'
>>> with request.urlopen(url) as f:
...     data = f.read()
...     print(f.status)

This may not work
Unverify global
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
Then use urllib.urlopen(‘ URL ‘)

Read More: