Unable to retrieve feeds
durden opened this issue · 4 comments
I'm using Python 3.6.6 on Mac OS and see the following error when running the realpython
script:
Traceback (most recent call last):
File "/Users/durden/.virtualenvs/reader/lib/python3.6/site-packages/feedparser.py", line 398, in __getattr__
return self.__getitem__(key)
File "/Users/durden/.virtualenvs/reader/lib/python3.6/site-packages/feedparser.py", line 356, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'title'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/durden/Documents/work/real_python/pyinstaller/reader/reader/__main__.py", line 84, in <module>
main()
File "/Users/durden/Documents/work/real_python/pyinstaller/reader/reader/__main__.py", line 78, in main
site = feed.get_site(url=url)
File "/Users/durden/Documents/work/real_python/pyinstaller/reader/reader/feed.py", line 25, in get_site
return u"{info.title} ({info.link})".format(info=info)
File "/Users/durden/.virtualenvs/reader/lib/python3.6/site-packages/feedparser.py", line 400, in __getattr__
raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'title'
I traced this down to some kind of SSL error so maybe I don't have something setup correctly? The error is a little confusing because the parsing doesn't return any feeds.
For example this line returns:
{'feed': {}, 'entries': [], 'bozo': 1, 'bozo_exception': URLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)'),)}
I'm able to read the XML feed correctly when pasting the url into Safari. I also saw a few related issues for feedparser
since that's likely where the 'problem' is:
I'm guessing it's something about my own SSL setup or the Python 3.6.6 I'm using not having the SSL module compiled correctly?
I can't remember for sure, but I think I'm using the Python directly from Python.org.
Found the solution! Apparently on OS X there's some certificate stuff that needs to be installed when using Python 3.6 from Python.org. See [this stack overflow post])https://stackoverflow.com/questions/49183801/ssl-certificate-verify-failed-with-urllib).
Essentially go to /Applications/Python 3.6
and run the Install Certificates.command
Ah, brilliant! Maybe we should add a small note about this in the Readme
?