简体   繁体   English

vscode中python的本地脚本调试

[英]Local script debugging for python in vscode

I am trying to follow the instructions mentioned on the vscode page for debugging a local python script .我正在尝试按照vscode 页面上提到的说明来调试本地 python 脚本 According to the instructions, I have added the piece of code to my script.根据说明,我已将这段代码添加到我的脚本中。 Next, I opened the integrated terminal and ran my script.接下来,我打开集成终端并运行我的脚本。 I get the message waiting for debugger to attach .我收到waiting for debugger to attach的消息。

Now I try to follow the step 6 of the instructions:现在我尝试按照说明的第 6 步进行操作:

Switch to the Run view, select the appropriate configuration from the debugger dropdown list, and start the debugger.切换到运行视图,select 从调试器下拉列表中进行适当的配置,然后启动调试器。

So, I click on the run and debug button (one on the bottom left in the picture) and then click Python: Attach using process id (top of the picture).因此,我单击运行和调试按钮(图片左下角的一个),然后单击Python: Attach using process id (图片顶部)。

在此处输入图像描述

However, the debugger does not get attached.但是,调试器没有附加。

I am not sure where am I going wrong.我不确定我哪里出错了。

Please check the content of the file " launch.json " you use for configuration debugging:请检查您用于配置调试的文件“ 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",
            
        }
    ]
}

then click F5 : The code stays at " debugpy.breakpoint() " as described in the documentation.然后单击F5 :代码停留在“ debugpy.breakpoint() ”,如文档中所述。

在此处输入图像描述

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

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