欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > python >内容正文

python

python中的bs4怎么导入_在Python 3.5导入BS4

发布时间:2025/3/12 python 39 豆豆
生活随笔 收集整理的这篇文章主要介绍了 python中的bs4怎么导入_在Python 3.5导入BS4 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

I have installed both Python 3.5 and Beautifulsoup4. When I try to import bs4, I get the error below. Is there any fix for that? Or should I just install Python 3.4 instead?

Please be very explicit - I am new to programming. Many thanks!

Traceback (most recent call last):

File "", line 1, in

File "C:\Python 3.5\lib\sit-packages\bs4\__init__.py", line 30, in

from .builder import builder_registry, ParserRejectionMarkup

File "C:\Python 3.5\lib\sit-packages\bs4\__init__.py", line 308, in

from . import _htmlparser

File "C:\Python 3.5\lib\sit-packages\bs4\_htmlparser.py", line 7, in

from html.parser import (

ImportError: cannot import name 'HTMLParseError'

解决方案

Update: Starting with 4.4.0, BeautifulSoup is compatible with Python 3.5. Upgrade:

pip install --upgrade beautifulsoup4

Old answer:

Because of the changes made for Deprecate strict mode of HTMLParser issue:

Issue #15114: the strict mode and argument of HTMLParser,

HTMLParser.error, and the HTMLParserError exception have been removed.

I'm afraid beautifulSoup4 is not compatible with Python 3.5 at the moment. Use Python 3.4.

总结

以上是生活随笔为你收集整理的python中的bs4怎么导入_在Python 3.5导入BS4的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。