我已成功在我的系统上安装bs4
(使用python setup.py install)。
现在的问题是在python中导入BeautifulSoup
时我遇到了以下错误:
C:\Users\dipankar>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\dipankar\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\__init__.py", line 29, in <module>
from .builder import builder_registry
File "C:\Users\dipankar\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\builder\__init__.py", line 294, in <module>
from . import _htmlparser
File "C:\Users\dipankar\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'
>>>
答案 0 :(得分:1)
做了很多谷歌搜索后
pip install --upgrade beautifulsoup4
为我工作。
答案 1 :(得分:-1)
您可以阅读here
因为从Python 3.3开始不推荐使用HTMLParseError 在Python 3.5中删除。
我会建议你使用其他解析器。查看BeautifulSoup Documentation