在WIN10上使用Visual Studio Code设置Python



我试图使用openCV从相机做一个小的颜色检测。我跟随并使用了这个youtube代码并下载了openCV。我还通过Visual Studio Code下载了Python和Code Runner扩展。

我一直得到一个错误,python没有安装.

我在这里做错了什么,因为我使用了从他的github

找到的视频相同的代码终端错误信息:

[Running] python -u "C:UsersLINEA~1.LAPAppDataLocalTemptempCodeRunnerFile.python"
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
[Done] exited with code=9009 in 2.123 seconds

https://github.com/CreepyD246/Simple-Color-Detection-with-Python-OpenCV

发生此错误是因为当您安装了VSC的Python扩展时,您没有安装Python解释器,这是一个单独的软件。您可以在这里找到Python安装程序。我建议将Python添加到PATH(安装过程中提供的一个选项)。

一旦你安装了Python,你仍然需要为OpenCV安装Python绑定。这可以在终端输入pip install opencv-python来完成。如果这不起作用,试试py -m pip install opencv-python

最新更新