简体   繁体   English

在命令行上使用“pip”安装 Python 模块后来自 Visual Studio 的 ModuleNotFoundError

[英]ModuleNotFoundError from Visual Studio after installing Python modules with “pip” on the command line

I am trying to install modules like tkinter , bs4 and numpy .我正在尝试安装tkinterbs4numpy等模块。

I use cmd and pip to install them, and it says that everything is installed fine.我使用cmdpip来安装它们,它说一切都安装得很好。

When I am using Visual Studio code it says当我使用 Visual Studio 代码时,它说

ModuleNotFoundError: No module named '....'

How can I find out if Python and the modules are in the same PATH?如何确定 Python 和模块是否在同一个 PATH 中?
Or what can i do to fix that?或者我能做些什么来解决这个问题?

I've tried to reinstall Python, but I get the same error.我试图重新安装 Python,但我得到了同样的错误。

Is it just the VSC?只是VSC吗?

File "c:/Users/Γιώργος Μαργα/Desktop/test.py", line 1, in <module>
    import numpy
ModuleNotFoundError: No module named 'numpy'

pip install is most likely installing globally into a Python interpreter that is different than the one that you have selected in VS Code. pip install很可能是全局安装到 Python 解释器中,该解释器与您在 VS Code 中选择的解释器不同。

if vscode not recognize your modules try to reload vscode.如果 vscode 无法识别您的模块,请尝试重新加载 vscode。

install modules with安装模块

 python3 -m pip install {new_module}

and then reload your Vs code make sure to set your Python interpreter within VSCode to the same as the one in your system path pythoninvscode然后重新加载您的 Vs 代码确保将 VSCode 中的 Python 解释器设置为与系统路径pythoninvscode中的解释器相同

Ok so i uninstall python and installed it again but this time i checked the box that said add that to PATH or someithng like this.好的,所以我卸载了 python 并再次安装,但这次我选中了将其添加到 PATH 或类似这样的框。 I also uninstalled python from the windowsstore however when it ry to run a code in VSC it doesnt do anything我还从 windowsstore 卸载了 python 但是当它试图在 VSC 中运行代码时它没有做任何事情

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

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