How To Fix Python Error Certificate Verify Failed: Unable To Get Local Issuer Certificate In Mac OS

When I run python code in mac os, I meet a certificate verify failed error like this ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056). This error confused me a lot of time. And after googling the error, I finally find the solution to fix it, below are the steps.

1. Fix Certificate Verify Failed: Unable To Get Local Issuer Certificate Error Steps.

  1. Open mac os finder, then click Applications ( on Finder window left side ) —> Python 3.7 folder (on Finder window right side) to expand it. Your python may have a different version. You can find the Install Certificates.command program in the Python 3.7 folder.
  2. Double click the Install Certificates.command file to run it. It will open another popup terminal window and show below command execution output text.
    Last login: Mon Jun 24 15:53:52 on ttys002
    /Applications/Python\ 3.7/Install\ Certificates.command ; exit;
    songs-MacBook-Pro:~ songzhao$ /Applications/Python\ 3.7/Install\ Certificates.command ; exit;
     -- pip install --upgrade certifi
    Requirement already up-to-date: certifi in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2019.6.16)
     -- 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.
    
    [Process completed]
    
  3. Close the popup window when the command runs completely successfully. Now run the python code again, and the Certificate Verify Failed Error will disappear.

2. Can Not Find The Program Install Certificates.command After Install Python 3 Using Home Brew On macOS.

2.1 Question(2022/08/05).

  1. I install python 3.6 on my MacBookPro, but I install it with the command brew install python3.
  2. When I run python code to download some files from an HTTPS web server, I encounter an error message like ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed.
  3. Then I follow this article and want to run the program Install Certificates.command, but I can not find the program. How to fix it.

2.2 Answer1.

  1. You can open the macOS terminal and run the command /Applications/Python\ 3.6/Install\ Certificates.command in it to fix the error.
  2. If the above method can not fix the issue, you can go to the python official website and download a newer python version installer.
  3. Run the python installer to install a newer version of python.
  4. Then you can find the program Install Certificates.command in your newer python install folder ( /Applications/Python ).
  5. You can run the program in the terminal to fix the issue.

5 thoughts on “How To Fix Python Error Certificate Verify Failed: Unable To Get Local Issuer Certificate In Mac OS”

  1. How to fix a similar thing on a windows machine? I am trying to install some packages and it’s giving me the same error.

  2. My python script use urllib.request package to retrieve a CSV file from a website. And I run the script on macOS Mojave with Python 3.7.

    The CSV file can be retrieved by both HTTPS and HTTP protocol URL, and when I use HTTPS protocol URL, this error occurred. And when I use HTTP protocol URL the error disappear.

    I know the HTTP protocol does not check the SSL certificate, maybe this avoid the error occurred with HTTPS protocol. So I found this article and the solution can fix my problem.

    But I do not know why it behaves different between HTTP and HTTPS protocol. I really want to find what does the Install\ Certificates.command program do at the back-end when I run it.

    Can anybody give me an answer? Thanks a lot.

  3. oh my god such a simple fix for such a complicated error message! XD your guide really helped a lot. thank you so much!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Clicky