SSL: CERTIFICATE_VERIFY_FAILED error when loading data into seaborn?
Asked Answered
P

4

9

I'm trying to load data from a github page (it's part of the standard seaborn datasets you can get.) I am on PyCharm and I don't understand what the hell is going on.

import seaborn as sns

data = sns.load_dataset("tips")

Then I get the error. Why am I getting this error?

/usr/local/bin/python3.7 "/Users/shahbhuiyan/Desktop/PyCharm Projects/Pandas/pycharmtest.py"

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


Pushbike answered 13/8, 2019 at 18:42 Comment(1)
Did you check #27836119Touter
U
16

I encountered the same issue and found the solution here: http://www.programmersought.com/article/2877138500/

Basically, just add these two lines of code, then try importing the data set:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context

This way, python will ignore verification of the security certificate

Upholsterer answered 27/4, 2020 at 2:40 Comment(1)
As a workaorund, it works but this actually disables the certificate verification. right?Wellfound
H
1

Open the terminal of MAC OS and try this command: "/Applications/Python 3.6/Install Certificates.command"

This works for me because Python 3.6 on MacOS uses an embedded version of OpenSSL, which does not use the system certificate store. More details here.

Howe answered 3/4, 2020 at 13:19 Comment(0)
S
0

By mwaskom, we know that

load_dataset pulls in csv files from https://github.com/mwaskom/seaborn-data and your system is failing to make a secure connection to it.

So, we can first download dataset from https://github.com/mwaskom/seaborn-data on our browser, and denote the path to the dataset directory by /path/to/seaborn-data, then we can let

data = sns.load_dataset('tips', data_home='/path/to/seaborn-data')

This way we can work around the issue produced by security certification without any risky side effect.

Slackjawed answered 21/10, 2022 at 13:20 Comment(0)
T
0

On Mac OS, for me the following worked on the command line:

First do this:
pip install certifi

And then do this, depending on your python version:
/Applications/Python\ 3.12/Install\ Certificates.command

Now you can get your seaborn datasets.

More info can be found in this question + answers:
urllib and "SSL: CERTIFICATE_VERIFY_FAILED" Error

Tenorio answered 21/1 at 15:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.