AttributeError: 'module' object has no attribute '_base'

较为完整的错误信息是:
class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):  
AttributeError: ‘module’ object has no attribute ‘_base’

大概就是说html5lib里面的treebuilders里面没有_base这个属性(其实就是找不到 _base 这个文件)
stackoverflow上查了很多种说法,有的说更新beautiful soup或者html5lib,有的说必须html5lib <= 0.999999
但是我的html5lib是刚下载的,就是这个版本(好像多了2个9…)

后来问了同事,发现只要去html5lib这个文件夹里(pip install的文件),找到treebuilders这个文件夹,然后看到里面的确没有_base.py。而是有一个base.py。我就把base.py前面加了一个_,改为_base.py。然后关掉sublime,再打开运行,就可以了!!!

以后’module’ object has no attribute (貌似经常见到)都可以用这个思路找找原因。


本文来自 codechelle 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/codechelle/article/details/56292200?utm_source=copy

猜你喜欢

转载自blog.csdn.net/Poisson_SHAN/article/details/82953781