在VSCode中直接执行Python代码的问题

http://stackoverflow.com/q/29987840/5295549
我参照stackoverflow上的一个answer那么做了,可是出现以下错误:

Failed to launch external program C:\Python35 
app.py. 
spawn C:\Python35 ENOENT 

请问是什么问题呢?

这是我的配置【只修改了下command路径】

{
    "version": "0.1.0",
    "command": "C:\\Python35",
    "args": ["app.py"],
    "problemMatcher": {
        "fileLocation": ["relative", "${workspaceRoot}"],
        "pattern": {
            "regexp": "^(.*)+s$",
            "message": 1
        }
    }
}
阅读 16k
3 个回答

就在这个SO下面有另一个回答,前段时间正好简单翻译了下。
看这里

{
    "version": "0.1.0",

    // The command is tsc. Assumes that tsc has been installed using npm install -g typescript
    "command": "C:\\Python35\\python",

    // The command is a shell script
    "isShellCommand": true,

    // Show the output window only if unrecognized errors occur.
    "showOutput": "always",

    // args is the HelloWorld program to compile.
    "args": ["${file}"],

    // use the standard tsc problem matcher to find compile problems
    // in the output.
    //"problemMatcher": "$tsc"
}

将配置做以上修改即可。

@frozenc 的方法已经被弃用了
详见这个回答
翻译如下:

所有这些答案现在已经过时了。

目前你必须:

安装Python语言扩展(和python,显然) 打开文件夹(重要!),打开该文件夹内的任何python文件
切换到调试“标签”(图标?),然后点击齿轮图标(提示“配置修复”launch.json“”)
保存打开的launch.json文件(它放在第2步中打开的文件夹中的.vscode 子文件夹中) 最后点击绿色三角形或点击F5
现在不需要额外的扩展或手动的launch.json编辑。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题