ImportError: cannot import name 'HTMLAwareEntitySubstitution'

蓝咒 提交于 2019-11-28 07:42:37

问题


I just setup beautifulsoup4-4.1.0 and upgrade pip to version 9.0.1. When I write this :

from bs4 import BeautifulSoup

error occurs:

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.


回答1:


In the version you have it appears that there might be an error in bs4/builder/__init__.py.

This line, from .. import _htmlparser should be: from . import _htmlparser

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.

To re-install: pip install --upgrade --force-reinstall beautifulsoup4



来源:https://stackoverflow.com/questions/40856104/importerror-cannot-import-name-htmlawareentitysubstitution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!