简体   繁体   中英

Installing beautifulsoup

I have installed beautifulsoup for Python, but it gives me this error when I import the library:

Traceback (most recent call last):
  File "D:/Playroom/WebScraper_01.py", line 2, in <module>
    from bs4 import BeautifulSoup
  File "C:\Python\lib\site-packages\bs4\__init__.py", line 29, in <module>
    from .builder import builder_registry
  File "C:\Python\lib\site-packages\bs4\builder\__init__.py", line 294, in <module>
    from . import _htmlparser
  File "C:\Python\lib\site-packages\bs4\builder\_htmlparser.py", line 7, in <module>
    from html.parser import (
ImportError: cannot import name 'HTMLParseError'

Does anyone know why?

  • If you get the ImportError “No module named HTMLParser”, your problem is that you're running the Python 2 version of the code under Python 3.

  • If you get the ImportError “No module named html.parser”, your problem is that you're running the Python 3 version of the code under Python 2.

See: https://www.crummy.com/software/BeautifulSoup/bs4/doc/#problems-after-installation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM