Skip to main content
 首页 » 编程设计

python之我已经安装了 beautifulsoup4,但是当我尝试在 python shell 中导入 bs4 时,出现 ModuleNotFound 错误

2025年01月19日9txw1958

我已经反复安装和卸载了 beautifulsoup4,但是无论我尝试做什么,当我尝试在 shell 中import bs4 时,我都会得到 ModuleNotFoundError。

我在 Windows 10 上使用 Python 3.6.4。我是编程新手,但正在阅读我的第三本 Python 书籍,这是我第一次在尝试导入模块时遇到大问题,包括我使用 pip 安装的模块。

请您参考如下方法:

你在写-

pip install beautifulsoup4 ?

这将只安装 beautifulsoup4 模块而不安装 bs4。

这样做:-

pip 安装 bs4

然后在你的 python 文件中执行此操作:-

从 bs4 导入 BeautifulSoup

此外,您可能需要管理员权限才能安装。