【问题标题】:VSCode I cannot 'Start Debugging' and 'Run Without Debugging'VSCode 我无法“开始调试”和“在没有调试的情况下运行”
【发布时间】:2021-07-07 06:01:47
【问题描述】:

我目前在 VSCode 中使用 python,当我按下“开始调试”或“不调试运行”时,这会出现在我的屏幕 中,因为我是初学者,所以我只是按下了顶部的(Carbon ComponentS)来运行但是这出现在我的屏幕上 我不知道我做错了什么,我已经尝试了几个小时,但我似乎找不到解决方案。我的 launch.Json 文件看起来像这样 有什么问题,我该如何解决?似乎这不是 python 的错,因为当我尝试运行 c++ 文件时它的行为也是一样的。谢谢。

按右上角的三角形是这样的

【问题讨论】:

  • 1.当你启动调试器时,你实际上是在一个带有 Python 扩展名的文件中,比如: foo.py 吗? 2. 你能验证你有一个可以运行的 Python 环境吗?在 VSCode IDE 的 Python 源文件中,您应该在 IDE 的左下方看到类似“Python 3.8.2”的内容。见:code.visualstudio.com/docs/python/python-tutorial
  • 我正在使用 Code Runner,当我单击右上角的三角形按钮时它工作正常。我安装了 Python 3.9.2 并且我的程序运行良好。但是,问题是当我按下“开始调试”时,它会出现如上图所示

标签: python visual-studio-code vscode-debugger


【解决方案1】:
  1. 在VS Code中,python代码的调试功能由“Python”扩展提供。因此,请在 VS Code 中安装和使用“Python”扩展。

  2. 在调试python之前,我们需要配置调试文件“launch.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",
        }
    ]
}

调试:

请参考此文档:Python debug configurations in Visual Studio Code

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-09
    • 2016-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多