【问题标题】:Error when importing beautifulsoup4 in python 3.5 in jupyter在jupyter的python 3.5中导入beautifulsoup4时出错
【发布时间】:2018-03-13 14:48:10
【问题描述】:

在 yupyter 中,我尝试导入 bs4,但出现错误:

/usr/local/lib/python3.5/dist-packages/bs4/builder/__init__.py in HTMLTreeBuilder()
232     """
233 
--> 234     preserve_whitespace_tags = HTMLAwareEntitySubstitution.preserve_whitespace_tags
    235     empty_element_tags = set([
    236         # These are from HTML5.

AttributeError: type object 'HTMLAwareEntitySubstitution' has no attribute 'preserve_whitespace_tags'

我完全卸载了 bs4 和 html5lib,然后再次重新安装它们仍然抛出相同的错误。 到处搜索这样的问题找不到解决方案。 如果有人可以提供帮助,我将不胜感激

奇怪的是我在使用 atom 时没有这个错误。

【问题讨论】:

    标签: beautifulsoup python-3.5


    【解决方案1】:

    来自AttributeError: type object 'HTMLAwareEntitySubstitution' has no attribute... Google Groups:

    • 要么尝试在 Canopy 中打开 Jupyter notebook,要么

    • 强制将 html5lib 降级到旧版本:

    pip install --upgrade html5lib==1.0b8
    

    【讨论】:

      猜你喜欢
      • 2015-06-13
      • 1970-01-01
      • 1970-01-01
      • 2016-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多