【问题标题】:ModuleNotFoundError: No module named 'bs4' even after installing and re-installingModuleNotFoundError:即使在安装和重新安装后也没有名为“bs4”的模块
【发布时间】:2023-03-27 00:10:01
【问题描述】:

我正在尝试运行我的 Python 文件。 (py name.py)

    from bs4 import BeautifulSoup as BS
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\bs4\__init__.py", line 29, in <module>
    from .builder import builder_registry
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\bs4\builder\__init__.py", line 294, in <module>
    from . import _htmlparser
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\bs4\builder\_htmlparser.py", line 7, in <module>
    from html.parser import (
ImportError: cannot import name 'HTMLParseError' from 'html.parser' (C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\html\parser.py)

我使用“pip”安装了这个库。 将库完全删除并重新安装后,运行此代码时会出现此错误。

  File "name.py", line 9, in <module>
from bs4 import BeautifulSoup as BS
ModuleNotFoundError: No module named 'bs4'

【问题讨论】:

  • 试试pip install -U beautifulsoup4
  • 你使用的是哪个python版本?
  • @user3401493 我用的是 3.7.3
  • @Thepersonwiththequestion:相关htmlparseerror-in-python3
  • @stovfl 那里指定的存储库不存在。

标签: python python-3.x beautifulsoup


【解决方案1】:

我解决了这个问题。首先,我从我的电脑中删除了所有提到的 BS4。然后在 CMD 中移动路径:

C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Scripts

并在那里使用命令:

pip install beautifulsoup4

【讨论】:

    最近更新 更多