【问题标题】:from bs4 import BeautifulSoup Error从 bs4 导入 BeautifulSoup 错误
【发布时间】:2017-10-24 16:38:08
【问题描述】:

导入 Beautiful Soup 时出现此错误。

from bs4 import BeautifulSoup
Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    from bs4 import BeautifulSoup
  File "C:\Users\pood1\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\__init__.py", line 30, in <module>
    from .builder import builder_registry, ParserRejectedMarkup
  File "C:\Users\pood1\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\builder\__init__.py", line 308, in <module>
    from . import _htmlparser
  File "C:\Users\pood1\AppData\Local\Programs\Python\Python36\lib\site-    packages\bs4\builder\_htmlparser.py", line 7, in <module>
    from html.parser import (
ImportError: cannot import name 'HTMLParseError'
Python:3.6.1 , BeautifulSoup:4-4.3.2

我该如何解决这个问题?

【问题讨论】:

  • 我解决了这个问题。谢谢你。问题是我的python版本。在我将版本更改为 3.5.3 后,此错误消失了!
  • 如果您解决了问题,请将解决方案添加为答案并将其标记为已接受。谢谢。

标签: python-3.x


【解决方案1】:

你能升级到最新版的美汤吗?

pip3 install --upgrade beautifulsoup4

这个错误应该在最新版本中得到修复。 BeautifulSoup 4.4.0 已更新为兼容 python3.5

【讨论】:

  • 谢谢。我解决了这个问题。非常感谢!!
  • 如果我的回答回答了你的问题,你能接受并投票吗?
猜你喜欢
  • 2012-12-12
  • 1970-01-01
  • 2015-07-09
  • 2018-10-06
  • 2015-04-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多