本文介绍了ImportError:无法导入名称"HTMLAwareEntitySubstitution"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是设置了beautifulsoup4-4.1.0并将pip升级到了9.0.1版本.当我写这篇文章时:
I just setup beautifulsoup4-4.1.0 and upgrade pip to version 9.0.1.When I write this :
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'
我该怎么办?非常感谢.
what should I do?Many thanks.
推荐答案
在该版本中,您似乎发现.
In the version you have it appears that there might be an error in bs4/builder/__init__.py
.
此行from .. import _htmlparser
应为:from . import _htmlparser
但是,我建议您使用最新版本的pip
重新安装软件包,然后再尝试使用常规的源代码.
However, I would suggest re-installing the package using current version of pip
before you go off the beaten path and try editing the source code.
要重新安装:pip install --upgrade --force-reinstall beautifulsoup4
这篇关于ImportError:无法导入名称"HTMLAwareEntitySubstitution"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!