python - ModuleNotFoundError:即使在安装和重新安装后也没有名为“bs4”的模块
问题描述
我正在尝试运行我的 Python 文件。(py名称.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'
解决方案
我解决了这个问题。首先,我从我的电脑中删除了所有提到的 BS4。然后在 CMD 中移动路径:
C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Scripts
.
并在那里花费了命令:
pip install beautifulsoup4
推荐阅读
- php - 在 Codeigniter 中过滤 Soap 请求
- php - 如何使用 php 和 Mysqli 在 Meta 关键字中使用多个数据
- javascript - 没有创建 Firebase App '[Default] - 调用 firebase.initializeApp()
- django - 如何在 django Admin 中隐藏文件字段 url
- sql - 联合表以从所有表中获取一组唯一记录的正确方法是什么?
- python - 当另一个变量最后一次等于 1 时赋值 1
- javascript - 前端的新日期()格式与后端的新日期()不同
- rx-java - RxJava 将对象与列表合并/合并
- excel - 如何使用 Powershell 脚本导出与特定 IIS 站点相关的证书详细信息
- javascript - 如何从 javascript 函数调用 vuejs 函数?