skip to Main Content

I did the manual installation on python 3.7.5 on Debian 8, when I will run the script I get this error:

<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)>

I saw several questions here in the stackoverflow more regarding MacOS, In my case this error is in Linux.

6

Answers


  1. THIS IS NOT A SOLUTION:
    I have encountered that several times, note however that i’m using windows, but i would assume that generally the resolving mehtods should be the same in principle for mac/linux.

    What i used to do is to force it to not verify the certificate by using the below:

    conda config --set ssl_verify false
    

    Note this is not a solution to the issue, it’s just a way to make the code run temporarily, or if you’re trying to download a library then that should do the trick until you download it. Note that the suggested below is not usually recommended, if you do it, after running your code/ downloading your library, remember to turn it back on using the below:

    conda config --set ssl_verify true
    
    Login or Signup to reply.
  2. I had the same issue. Here is what I found helped my problem.

    import ssl
    
    ssl._create_default_https_context = ssl._create_unverified_context
    

    Please see here for the original answer from markroxor. Hope it will help your problem as well.

    Login or Signup to reply.
  3. I had

    <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)>
    

    With python3 3.9.2-3, and other python related packages with the same, or similar, version. On Debian GNU/Linux 11 (Bullseye).

    At first, using the suggested

    import ssl
    ssl._create_default_https_context = ssl._create_unverified_context
    

    managed to solve the problem. Though I do not know if, and which, down sides, or other side effects, this solution has.

    Afterwards, I noticed the /etc/ssl/certs/ folder is empty. Installing the ca-certificates package fills in this folder. Which seem to be another solution, in which those 2 python ssl lines are not required. You can see here the detailed list of files the ca-certificates package installed. This article, from 2015, with a last comment from 2017, discusses the location of ca-certificates in various OSs/distributions. I think the ca-certificates package is rather basic, and is usually installed as part of the initial installation of the machine. I do not know how it was missing from that particular machine.

    Login or Signup to reply.
  4. If this happened after you installed a python version manually, inside the python app folder, double click on the "Install Certificates.command" file and it should fix it.

    Login or Signup to reply.
  5. What worked for my MacOs:

    1. Open the finder

    2. Find the version of Python that you are using

    3. Open its folder

    4. Click on the "Install Certificates.command". It will open a terminal and install the certificate.

    Login or Signup to reply.
  6. In my case (Dell computer), the SSL problem was caused by Dell software itself:
    reported here. In that case, according to this answer to another question in the SE network, you can solve the problem by running the following command:

    sudo cp /usr/lib/x86_64-linux-gnu/libcrypto.so.3 /opt/dell/dcc/libcrypto.so.3
    

    And then, run this:

    sudo update-ca-certificates --fresh
    

    It worked for me on a Dell Latitude 7310, LinuxMint21. November 2022.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search