talkpython / 100daysofcode-with-python-course

Course materials and handouts for #100DaysOfCode in Python course
https://training.talkpython.fm/courses/explore_100days_in_python/100-days-of-code-in-python
MIT License
2.09k stars 1.07k forks source link

Day05 exercise - SSL: CERTIFICATE_VERIFY_FAILED #6

Closed davebrochu closed 6 years ago

davebrochu commented 6 years ago

I tried recreating the day 5 example found in the provided notebook on my machine in Pycharm and am getting a SSL: CERTIFICATE_VERIFY_FAILED error when the movies file is being downloaded using urlretrieve. I am able to reproduce this when running the script from the terminal as well. Not sure if something happened with the cert on raw.githubusercontent.com

from urllib.request import urlretrieve

movie_data = 'https://raw.githubusercontent.com/pybites/challenges/solutions/13/movie_metadata.csv'
movies_csv = 'movies.csv'
urlretrieve(movie_data, movies_csv)

Traceback (most recent call last): File "movieparse.py", line 6, in <module> urlretrieve(movie_data, movies_csv) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 248, in urlretrieve with contextlib.closing(urlopen(url, data)) as fp: File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen return opener.open(url, data, timeout) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open response = self._open(req, data) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open '_open', req) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain result = func(*args) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open context=self._context, check_hostname=self._check_hostname) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>

davebrochu commented 6 years ago

This appears to have been an issue with my Mac setup. I followed the instructions found in this article to resolve, should anyone else encounter the issue

https://stackoverflow.com/questions/41691327/ssl-sslerror-ssl-certificate-verify-failed-certificate-verify-failed-ssl-c

mikeckennedy commented 6 years ago

That is weird. I’m glad you tracked it down to a system config problem! On Wed, Apr 11, 2018 at 18:07 davebrochu notifications@github.com wrote:

Closed #6 https://github.com/talkpython/100daysofcode-with-python-course/issues/6.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/talkpython/100daysofcode-with-python-course/issues/6#event-1569888251, or mute the thread https://github.com/notifications/unsubscribe-auth/AB8PaZ284XzaW4gIN4JsBhwssVBMoOeSks5tnqi1gaJpZM4TQ93E .