-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Hello Joe,
I benefit a lot from your Python course on LinkedIn. Thank you so much for such great sharing. Today, I run into one minor problem with the JSONData
chapter, namely with this file:
The code runs perfectly with Python 3.9.16
, but I use Python 3.11.4
for the learning purpose, then I got an error from this method urllib.request.urlopen(urlData)
, the terminal says:
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1002)>
The error screenshot looks like this:

I think this should be some kind of version incompatibility issue with Python. And after some investigation, I figure out this can be resolved with a ssl context as follows:
import urllib.request
import ssl
# ...some other code logic ...
urlData = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_hour.geojson"
context = ssl._create_unverified_context()
webUrl = urllib.request.urlopen(urlData, context=context)
print("result code:", str(webUrl.getcode()))
# ... some other code logic ...
Not sure if this is necessary to clarify in your demo code, I presume there will be more and more software developers using Python 3.11.4 above
in the future who are going to take this course since it is so popular and practical, they would run into this problem as well.
Could you please help take a look this. Thank you!