beautifulsoup, html5lib: module object has no attr

2019-01-21 15:38发布

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?

5条回答
Explosion°爆炸
2楼-- · 2019-01-21 16:17

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

查看更多
姐就是有狂的资本
3楼-- · 2019-01-21 16:19

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.

查看更多
家丑人穷心不美
4楼-- · 2019-01-21 16:21

I upgraded beautifulsoup4 and html5lib and it resolved the issue.

pip install --upgrade beautifulsoup4
pip install --upgrade html5lib
查看更多
该账号已被封号
5楼-- · 2019-01-21 16:27

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

查看更多
戒情不戒烟
6楼-- · 2019-01-21 16:35

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"
查看更多
登录 后发表回答