Sunday, May 16, 2021

urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] macOS

 Error Details

 File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1346, in do_open

    h.request(req.get_method(), req.selector, req.data, headers,

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1253, in request

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

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1299, in _send_request

    self.endheaders(body, encode_chunked=encode_chunked)

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1248, in endheaders

    self._send_output(message_body, encode_chunked=encode_chunked)

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1008, in _send_output

    self.send(msg)

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 948, in send

    self.connect()

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1422, in connect

    self.sock = self._context.wrap_socket(self.sock,

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 500, in wrap_socket

    return self.sslsocket_class._create(

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1040, in _create

    self.do_handshake()

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1309, in do_handshake

    self._sslobj.do_handshake()

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)


During handling of the above exception, another exception occurred:


Solution


Go to Macintosh HD > Applications > Python3.9 folder (whatever version of python you're using) > double click on "Install Certificates.command" file


Output


The default interactive shell is now zsh.

To update your account to use zsh, please run `chsh -s /bin/zsh`.

For more details, please visit https://support.apple.com/kb/HT208050.

/Applications/Python\ 3.9/Install\ Certificates.command ; exit;

admins-MBP:~ admin$ /Applications/Python\ 3.9/Install\ Certificates.command ; exit;

 -- pip install --upgrade certifi

Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (2020.12.5)

 -- removing any existing file or link

 -- creating symlink to certifi certificate bundle

 -- setting permissions

 -- update complete

logout

Saving session...

...copying shared history...

...saving history...truncating history files...

...completed.

Deleting expired sessions...none found.


[Process completed]


No comments: