来自bs4导入BeautifulSoup错误

时间:2017-05-24 11:07:54

标签: python-3.x

导入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

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

您可以升级到最新版的Beautiful Soup吗?

pip3 install --upgrade beautifulsoup4

此错误应在最新版本中修复。 BeautifulSoup 4.4.0已更新为python3.5兼容