beautifulsoup - 导入错误 : cannot import name 'HTMLAwareEntitySubstitution'

标签 beautifulsoup python-3.5

我只是设置了 beautifulsoup4-4.1.0 并将 pip 升级到版本 9.0.1。
当我写这个时:

from bs4 import BeautifulSoup

发生错误:
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    from bs4 import BeautifulSoup
  File "D:\Program Files (x86)\Python35-32\lib\site-packages\bs4\__init__.py", line 35, in <module>
    from .builder import builder_registry, ParserRejectedMarkup
  File "D:\Program Files (x86)\Python35-32\lib\site-packages\bs4\builder\__init__.py", line 7, in <module>
    from bs4.element import (
ImportError: cannot import name 'HTMLAwareEntitySubstitution'

我该怎么办?非常感谢。

最佳答案

在您拥有的版本中,似乎有 might be an errorbs4/builder/__init__.py .

这条线,from .. import _htmlparser应该是:from . import _htmlparser
但是,我建议使用当前版本的 pip 重新安装该软件包。在你离开人迹罕至的道路并尝试编辑源代码之前。

重新安装:pip install --upgrade --force-reinstall beautifulsoup4

关于beautifulsoup - 导入错误 : cannot import name 'HTMLAwareEntitySubstitution' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40856104/

相关文章:

python - 使用带有 UTF-8 的 soup.get_text()

python - 要抓取的网站具有不同的类名

python - 使用套接字 API 编写基本的 HTTP 服务器

python - 漂亮的汤检查标签中的标签

python - 从 HTML 标签中移除某些属性

python - BeautifulSoup : Accessing <li> elements from <ul> with no id

python - 我们如何在同一 Ubuntu 操作系统上分别使用、维护和安装 python 2.7 和 python 3.5 的库?

numpy - `out` 中的 `numpy.einsum` 参数无法按预期工作

linux - Python3 root sudo venv

python - 是否可以使用列表理解从一个字典的字典创建所有成员字典键的列表?