导入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
我该如何解决这个问题?
答案 0 :(得分:1)
您可以升级到最新版的Beautiful Soup吗?
pip3 install --upgrade beautifulsoup4
此错误应在最新版本中修复。 BeautifulSoup 4.4.0已更新为python3.5兼容