简体   繁体   English

安装beautifulsoup

[英]Installing beautifulsoup

I have installed beautifulsoup for Python, but it gives me this error when I import the library:我已经为 Python 安装了 beautifulsoup,但是当我导入库时它给了我这个错误:

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.如果您收到 ImportError “No module named HTMLParser”,则您的问题是您正在 Python 3 下运行 Python 2 版本的代码。

  • 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.如果您收到 ImportError “No module named html.parser”,则您的问题是您正在 Python 2 下运行 Python 3 版本的代码。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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