1

我是编程和 Python 的新手。我正在尝试在 Python3 上安装 BeutifulSoup 来学习 MOOC 的网络抓取(使用 Jupyter Notebooks 作为 IDE)。当我运行时,from bs4 import BeautifulSoup我收到以下错误

AttributeError Traceback (last last call last) in 3 import ssl 4 print("done2") ----> 5 from bs4 import BeautifulSoup 6 print("done3")

~\Desktop\py4e\code3\code3\bs4__init__.py in 28 import warnings 29 ---> 30 from .builder import builder_registry, ParserRejectedMarkup 31 from .dammit import UnicodeDammit 32 from .element import (

~\Desktop\py4e\code3\code3\bs4\builder__init__.py in ' 312 register_treebuilders_from(_htmlparser) 313 try: --> 314 from . import _html5lib 315 register_treebuilders_from(_html5lib) 316 除了 ImportError:

~\Desktop\py4e\code3\code3\bs4\builder_html5lib.py in 68 69 ---> 70 类 TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder): 71 72 def init (self, soup, namespaceHTMLElements):

AttributeError:模块“html5lib.treebuilders”没有属性“_base”

我尝试了以下解决方案:

1) pip install html5lib==0.9999999 2) pip install --upgrade html5lib==1.0b8 3) pip install --upgrade bleach==1.4.2 3) 更新 BeutifulSoup (pip install) 4) 降级后重新安装 html5lib 到最新版本不起作用

非常感谢您的帮助!

4

0 回答 0