8

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)>


3 Answers3

14

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

Romy Li
  • 141
  • 1
  • 3
  • 1
    As a workaorund, it works but this actually disables the certificate verification. right? – Rene Apr 27 '21 at 10:20
0

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.

Med El
  • 1
  • 2
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.