3

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.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
JB_
  • 533
  • 1
  • 6
  • 18

7 Answers7

9

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.

JingMT
  • 101
  • 1
  • 3
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.

nh4c
  • 31
  • 4
3

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.

Maiia Bocharova
  • 149
  • 1
  • 7
1

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.

Carlos Pinzón
  • 1,286
  • 2
  • 15
  • 24
0

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
mIT
  • 48
  • 6
0

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.

Guil
  • 1
0

The source I found for the "Install Certificates" command is located here: https://gist.github.com/marschhuynh/31c9375fc34a3e20c2d3b9eb8131d8f3

Add this as a new file to your python directory for future use if needed. I called mine "Install Certificates.py". Then I simply ran (double clicked) the file and it installed a certificate. Now I have an https connection. Hopefully this works for you.

(Adding this as new file is as easy as creating an empty .txt file and pasting the code in, then save it. Finally change the extension to .py and double click the file to run it.)