ImportError: cannot import name 'HTMLAwareEntitySubstitution'

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

from bs4 import BeautifulSoup

an 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.

+4
source share
1 answer

In the version you have, there may be a bug in bs4/builder/__init__.py.

This line from .. import _htmlparsershould be:from . import _htmlparser

However, I would suggest reinstalling the package using the current version pipbefore you leave the prototype path and try editing the source code.

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

+12
source

Source: https://habr.com/ru/post/1662206/


All Articles