Using BeautifulSoup4 on Python3
Fired up my Ubuntu machine and got the following error. My web scraping script runs BeautifulSoup4 and was working so far. The only thing I did recently was install Audacity. Don't know how that could affect BeautifulSoup.
Traceback (most recent call last): File "scrubNprint.py", line 1, in <module> from bs4 import BeautifulSoup File "/usr/lib/python3/dist-packages/bs4/__init__.py", line 30, in <module> from .builder import builder_registry, ParserRejectedMarkup File "/usr/lib/python3/dist-packages/bs4/builder/__init__.py", line 314, in <module> from . import _html5lib File "/usr/lib/python3/dist-packages/bs4/builder/_html5lib.py", line 70, in <module> class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
AttributeError: module 'html5lib.treebuilders' has no attribute '_base'The error from .builder import builder_registry, ParserRejectedMarkup, I have searched my directory list and I don't seem to find the script builder.
The error from . import _html5lib, the file seems to be there in the directory bs4/builder. I don't understand why I am getting this error.
The last error
class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
AttributeError: module 'html5lib.treebuilders' has no attribute '_base'is unclear to me. It appears to be in the script.
More importantly, I did not touch anything that I know of. But I might have done an update before installing Audacity. However, I don't think updating Ubuntu should have affected BeautifulSoup.
When I do pip3 --user uninstall beautifulsoup4 I get a message that --user is invalid.
I did pip uninstall, then tried a reinstall. Still getting the same error messages.
beautifulsoup is installed. the results of the command you asked for is;
python-bs4: Installed: (none) Candidate: 4.4.1-1 Version table: 4.4.1-1 500 500 xenial/main amd64 Packages 500 xenial/main i386 Packages
python3-bs4: Installed: 4.4.1-1 Candidate: 4.4.1-1 Version table: *** 4.4.1-1 500 500 xenial/main amd64 Packages 500 xenial/main i386 Packages 100 /var/lib/dpkg/statusMy python code is correct. it was working for 5 months. then, all of sudden I got the traceback error above. which has not gone away, after deleting and reinstalling beautifulsoup (see this post.
There is a bug in the current release of the html5lib that causes the error, and it should be fixed in a few weeks.