py4e icon indicating copy to clipboard operation
py4e copied to clipboard

urllinks.py sample code needs an import update to run beautifulsoup

Open nratzan opened this issue 3 years ago • 1 comments

Hi Dr. Chuck,

I love the py4e courses! Thank you.

The urllinks.py sample code needs updating so beautiful soup works with newer versions of python, e.g. 3.10.

I'm getting an error saying the module collections isn't callable.

I found a solution on stackoverflow:

The urllinks.py file should have this included:

import collections
collections.Callable = collections.abc.Callable

Thank you for making so many great, free resources! Noah

nratzan avatar Jul 08 '22 14:07 nratzan

Thanks Noah - this summer I will be going through these issues and fixing the course content.

csev avatar Jul 08 '22 14:07 csev

Hi Noah, The version in https://www.py4e.com/code3/urllinks.py is working fine it seems. I have checked it both on Replit and Google Colab as well colab replit

pravintargaryen avatar Feb 01 '23 09:02 pravintargaryen

Noah, That is a sort of fudge workaround, in several searches. Yes, it's likely an issue on www.py4e.com. A message is needed, while in the version on Coursera PY4E the TA's have a pinned post. Which is, Python 3.10 remove the bs4 folder when using the code3.zip & pip install beautifulsoup4. For earlier versions of Python keep the bs4 folder, don't install beautifulsoup4 Updating the bs4.zip would also work, and the extra instructions could possibly be removed. Following the Python end-of-life dates.

srcatto avatar Mar 19 '23 21:03 srcatto

I have update the bs4.zip folder to latest python and included dependencies - so it should work without change to the documentation. Which is nice.

csev avatar Jan 01 '24 18:01 csev