繁体   English   中英

在VS代码中,由于某种原因,我无法运行任何python文件,因为它在cmd中写入python而不是py。 反正有解决办法吗?

[英]In VS code, for some reason i cannot run any python file because it writes python instead of py in cmd. is there anyway to fix it?

在vs代码中,由于某种原因,我无法运行任何python代码,因为vs代码将python而不是cmd中的py放入了python中。 它显示了这一点:

[运行中] python -u“ c:\\ Users ...”

但应该显示此:

[运行中] py -u“ c:\\ Users \\

我尝试过在线搜索如何修复它,错误消息:

无法将“ python”识别为内部或外部命令,可操作程序或批处理文件。

但给出了无用的答案

import pygame
pygame.init()
screen = pygame.display.set_mode((360,360))

输出内容:

[运行中] python -u“ c:\\ Users ...”

如您所见,它输入了错误的命令,我不知道如何解决它。 预期的输入:

[运行中] py -u“ c:\\ Users ...”

好了,您可以通过按Ctrl+Shift+P然后搜索Python: Select Interpreter来更改Code使用的解释器Python: Select Interpreter ,这对于在IDE中运行代码很有帮助。 如果那不起作用,您可以尝试使用Code中的内置终端通过py命令手动运行代码。

在VSCODE调试模式下,我按以下方式启动json,然后可以轻松地用断点调试代码

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [{
    "name": "Python: Current File",
    "type": "python",
    "request": "launch",
    "program": "${file}",
    "console": "integratedTerminal"
}]

}

暂无
暂无

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

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