[Python] How to fix 'SSL: CERTIFICATE_VERIFY_FAILED' error only thrown in Pycharm?

Discussão em 'Python' iniciado por Stack, Março 6, 2025.

  1. Stack

    Stack Membro Participativo

    When making an https request in Pycharm using a Python3 interpreter I receive the error:

    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)

    I'm inclined to assume this is a problem with my Pycharm configuration as this problem only occurs in Pycharm when using any version of Python3. The code runs fine in Pycharm using Python2.7 and it works fine running Python3 in commandline.

    Through Pycharm I have tried creating new virtual environments using different versions of Python3. All of which based on interpreters that can successfully run the code independent of Pycharm.

    The most common solution to this error is to run Install Certificates.command found at /Applications/Python 3.x/ but running this only confirms that the certifi package is already up-to-date.

    The last line of the code below throws the error:

    headers = {"authuser":username, "authpass":password}
    conn = http.client.HTTPSConnection(url)
    conn.request("POST",requestpath, headers)

    Continue reading...

Compartilhe esta Página