我刚刚安装了 beautifulsoup4-4.1.0 并将 pip 升级到版本 9.0.1。
当我写这个时:
from bs4 import BeautifulSoup
出现错误:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
from bs4 import BeautifulSoup
File "D:\Program Files (x86)\Python35-32\lib\site-packages\bs4\__init__.py", line 35, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "D:\Program Files (x86)\Python35-32\lib\site-packages\bs4\builder\__init__.py", line 7, in <module>
from bs4.element import (
ImportError: cannot import name 'HTMLAwareEntitySubstitution'
我该怎么办?非常感谢。
在您拥有的版本中似乎有可能是一个错误 https://stackoverflow.com/questions/22182634/beautifulsoup4-throwing-an-error-in-python-3-x in bs4/builder/__init__.py
.
这条线,from .. import _htmlparser
应该:from . import _htmlparser
但是,我建议使用当前版本重新安装该软件包pip
在你走出常规并尝试编辑源代码之前。
重新安装:pip install --upgrade --force-reinstall beautifulsoup4
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)