在Python 3.5中导入bs4
我已经安装了Python 3.5和Beautifulsoup4。当我尝试导入bs4时,出现以下错误。有什么解决办法吗?还是应该只安装Python3.4?请非常明确-我是编程新手。非常感谢!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python 3.5\lib\sit-packages\bs4\__init__.py", line 30, in <module>
from .builder import builder_registry, ParserRejectionMarkup
File "C:\Python 3.5\lib\sit-packages\bs4\__init__.py", line 308, in <module>
from . import _htmlparser
File "C:\Python 3.5\lib\sit-packages\bs4\_htmlparser.py", line 7, in <module>
from html.parser import (
ImportError: cannot import name 'HTMLParseError'
-
更新: 从4.4.0开始,
BeautifulSoup
与Python 3.5兼容。升级:pip install --upgrade beautifulsoup4
旧答案:
由于对“不赞成使用HTMLParser的严格模式”问题进行了更改,因此:
问题#15114:HTMLParser,HTMLParser.error和HTMLParserError异常的严格模式和参数已删除。
恐怕
beautifulSoup4
目前与Python 3.5不兼容。使用Python 3.4。