Traceback Error with Python3 and Beautiful Soup (Chapter 12 PY4E)

guys. I’m on chapter 12 of my PY4E studies, and I’m a bit stumped. I’ve downloaded Beautiful Soup, and I can’t get my computer to recognize it. I’m being hit with a traceback error and and attribute error.

traceback:
Traceback (most recent call last):
File “/Users/name/Desktop/py4e/beausoup.py”, line 12, in
soup = BeautifulSoup(html, “html.parser”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
attribute:
File “/Users/name/Desktop/py4e/bs4/element.py”, line 1565, in _normalize_search_value
if (isinstance(value, str) or isinstance(value, collections.Callable) or hasattr(value, ‘match’)

Entire Error Message:
Enter URL: https://py4e-data.dr-chuck.net/comments_42.html
Traceback (most recent call last):
File “/Users/nylespollonais/Desktop/py4e/beausoup.py”, line 12, in
soup = BeautifulSoup(html, “html.parser”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/name/Desktop/py4e/bs4/init.py”, line 215, in init
self._feed()
File “/Users/name/Desktop/py4e/bs4/init.py”, line 239, in _feed
self.builder.feed(self.markup)
File “/Users/name/Desktop/py4e/bs4/builder/_htmlparser.py”, line 164, in feed
parser.feed(markup)
File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/html/parser.py”, line 110, in feed
self.goahead(0)
File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/html/parser.py”, line 170, in goahead
k = self.parse_starttag(i)
^^^^^^^^^^^^^^^^^^^^^^
File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/html/parser.py”, line 337, in parse_starttag
self.handle_starttag(tag, attrs)
File “/Users/name/Desktop/py4e/bs4/builder/_htmlparser.py”, line 62, in handle_starttag
self.soup.handle_starttag(name, None, None, attr_dict)
File “/Users/name/Desktop/py4e/bs4/init.py”, line 404, in handle_starttag
self.currentTag, self._most_recent_element)
^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/name/Desktop/py4e/bs4/element.py”, line 1001, in getattr
return self.find(tag)
^^^^^^^^^^^^^^
File “/Users/name/Desktop/py4e/bs4/element.py”, line 1238, in find
l = self.find_all(name, attrs, recursive, text, 1, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/name/Desktop/py4e/bs4/element.py”, line 1259, in find_all
return self._find_all(name, attrs, text, limit, generator, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/name/Desktop/py4e/bs4/element.py”, line 516, in _find_all
strainer = SoupStrainer(name, attrs, text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/name/Desktop/py4e/bs4/element.py”, line 1560, in init
self.text = self._normalize_search_value(text)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/name/Desktop/py4e/bs4/element.py”, line 1565, in _normalize_search_value
if (isinstance(value, str) or isinstance(value, collections.Callable) or hasattr(value, ‘match’)
^^^^^^^^^^^^^^^^^^^^

I have moved the bs4 folder into the py4e coding folder with my other programs, I’ve left it on the desktop… it just isn’t working and I don’t know why. I can figure out the code for the assignment, but I just need help in assisting my computer in finding Beautiful Soup. I’m not sure if it is not being called or why it just won’t work. I don’t even know what’s going on with the other lines yet – either.

Leave a Comment