beautifulsoup, html5lib: module object has no attribute _base
Asked Answered
N

8

67

When I updated my packages I have this new error:

class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
AttributeError: 'module' object has no attribute '_base'

I tried to update beautifulsoup, with no more result. How can I fix that?

Nostrum answered 19/7, 2016 at 0:14 Comment(0)
N
20

edit nov, 2017: it seems this doesn't work any more

Finally found out, a search engine didn't throw anything but it's referenced on beautifulsoup's issue tracker: https://bugs.launchpad.net/beautifulsoup/+bug/1603299

it works back with html5lib v0.9999999 (7 nines)

"html5lib<=0.9999999"
Nostrum answered 19/7, 2016 at 0:18 Comment(5)
This fixes a similar bug in kaggle-cli tooGlutton
(on W7).Unfortunately i tried both downgrading and upgrading.I also tried to seta virtual env using Python 2.7. Nothing worked so far, basically I am stuck on using beautifulsoup libraryAuthorship
I just overcome this error simply checking that Pycharm was using the wrong interpreter in my virtual env. Indeed in the python idle and Powershell I did not faced such errorAuthorship
html5lib<=0.9999999 has a security vulnerability and should not be used any longer. Source: sourceclear.com/registry/security/cross-site-scripting-xss-/…Intermix
This is the command to fix it: sudo pip install html5lib==0.9999999Overthrust
D
117

I upgraded beautifulsoup4 and html5lib and it resolved the issue.

pip install --upgrade beautifulsoup4
pip install --upgrade html5lib
Discobolus answered 6/8, 2016 at 1:3 Comment(2)
Confirmed that this worked to get the sudo pip install spry to work properly without errors February 2017.Klara
I required --forceDebase
S
27

This is an issue with upstream package html5lib: https://bugs.launchpad.net/beautifulsoup/+bug/1603299 To fix, force downgrade to an older version:

pip install --upgrade html5lib==1.0b8

Shook answered 15/12, 2016 at 10:1 Comment(0)
N
20

edit nov, 2017: it seems this doesn't work any more

Finally found out, a search engine didn't throw anything but it's referenced on beautifulsoup's issue tracker: https://bugs.launchpad.net/beautifulsoup/+bug/1603299

it works back with html5lib v0.9999999 (7 nines)

"html5lib<=0.9999999"
Nostrum answered 19/7, 2016 at 0:18 Comment(5)
This fixes a similar bug in kaggle-cli tooGlutton
(on W7).Unfortunately i tried both downgrading and upgrading.I also tried to seta virtual env using Python 2.7. Nothing worked so far, basically I am stuck on using beautifulsoup libraryAuthorship
I just overcome this error simply checking that Pycharm was using the wrong interpreter in my virtual env. Indeed in the python idle and Powershell I did not faced such errorAuthorship
html5lib<=0.9999999 has a security vulnerability and should not be used any longer. Source: sourceclear.com/registry/security/cross-site-scripting-xss-/…Intermix
This is the command to fix it: sudo pip install html5lib==0.9999999Overthrust
E
8

The downgrade to html5lib 1.0b8 in @Bhavuk answer works but courses a version issue with bleach.

The solution for me was with a change of version of bleach to be compatible with the new version of html5lib

pip install --upgrade bs4
pip install --upgrade bleach==1.4.2
pip install --upgrade html5lib==1.0b8

Python version 3.5

Embrace answered 22/4, 2018 at 6:20 Comment(1)
For anaconda, I did conda install html5lib==0.9999999, which downgraded bleach to 1.5.0 but it workedGeorganngeorge
F
3

The same problem occurred on me. I don't know what you were trying to do, but it occurred on me when I tried to read XML file in pandas, using pd.read_html().

The problem is fixed by upgrading all of beautifulsoup4, html5lib, and lxml, like:

pip install bs4
pip install html5lib
pip install lxml

And restart your Python environment and now it is working.

Foulup answered 11/9, 2016 at 10:22 Comment(1)
I needed to add -U to upgrade existing installations in some cases, but this worked for me.Reduplicate
K
0

This command solved the problem for me:

 sudo pip install html5lib==0.9999999
Kenweigh answered 24/6, 2019 at 17:57 Comment(0)
P
0

Just install html5lib using this because if you install the normal way then you have to spider using python2.

sudo pip3 install html5lib==0.9999999
Parody answered 17/5, 2020 at 15:38 Comment(0)
H
0

I found trying to switch versions did not work for me. In the end, based on this issue I edited the relevant file at ~/.local/lib/python3.7/site-packages/bs4/builder/_html5lib.py for my purposes.

Helping answered 4/11, 2020 at 22:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.