在Python 3.5中导入bs4

ann*_*e_t 15 python beautifulsoup html-parsing python-3.x python-3.5

我已经安装了Python 3.5和Beautifulsoup4.当我尝试导入bs4时,我收到以下错误.那有什么问题吗?或者我应该只安装Python 3.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'
Run Code Online (Sandbox Code Playgroud)

ale*_*cxe 27

更新:从4.4.0开始,BeautifulSoup与Python 3.5兼容.升级:

pip install --upgrade beautifulsoup4
Run Code Online (Sandbox Code Playgroud)

老答案:

由于对HTMLParser问题的Deprecate严格模式所做的更改:

问题#15114:删除了HTMLParser,HTMLParser.error和HTMLParserError异常的严格模式和参数.

我担心beautifulSoup4目前与Python 3.5不兼容.使用Python 3.4.


Ani*_*ift 19

更新:BeautifulSoup 4.4.0已经更新为python3.5兼容,所以pip install --upgrade beautifulsoup4如果你仍然遇到这个问题,应该这样做.