简体   繁体   English

ModuleNotFoundError:Visual Studio Code 中没有名为“bs4”的模块

[英]ModuleNotFoundError: No module named 'bs4' just in Visual Studio Code

I have a.py script which I have open in Virtual Studio Code.我有一个在 Virtual Studio Code 中打开的 .py 脚本。 One of my libraries (bs4) is not getting imported successfully, it says:我的一个库 (bs4) 没有成功导入,它说:

ModuleNotFoundError: No module named 'bs4'

I've tried to pip install bs4 in my command line, but the library was already there.我尝试在我的命令行中 pip 安装 bs4,但该库已经存在。

However, I've run the exact same script in Jupyter Notebooks (installed by anaconda package) and the library existed and the script worked as expected.但是,我在 Jupyter Notebooks(由 anaconda 包安装)中运行了完全相同的脚本,并且库存在并且脚本按预期工作。

How can I get VS Code to use the same libraries as Jupyter Notebooks is using?如何让 VS Code 使用与 Jupyter Notebooks 正在使用的库相同的库?

Try changing the python 3 interpreter:尝试更改 python 3 解释器:

Your system almost certainly has more than one Python installation.您的系统几乎肯定有不止一个 Python 安装。 Running pip from the command line is working with a different version to the one that Visual Studio Code is configured to use从命令行运行pip使用的版本与 Visual Studio Code 配置使用的版本不同

Please use this command for installing bs4 on Visual Studio Code on the terminal:请使用此命令在终端的 Visual Studio Code 上安装bs4

py -m pip install bs4

Don't use this:不要使用这个:

pip install bs4

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

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