0

I have stumbled into an url error when trying to read a csv-file with the pandas library in python. I'm running python 3.9.6 in Windows.

import pandas as pd

url = 'Some_url_to_a_csv'
df = pd.read_csv(url)

This returns an "urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)".

I found a solution involving the ssl library, that I found from "https://stackoverflow.com/questions/44629631/while-using-pandas-got-error-urlopen-error-ssl-certificate-verify-failed-cert". This is the code:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context

After adding this line of code, it worked. But then I wonder - what does the code do, and why does it work? Does it just skip the verification process? And is there a more permanent solution to the problem? As in not having to run this code every time?

0 Answers0