首页 > 解决方案 > Python调试器在vscode中没有响应

问题描述

当我从 vscode 调试我的 python 代码时,调试器在我的终端上没有显示任何响应和任何内容。

我已经用带有断点的简单 hello world 代码对其进行了测试。没有输出和断点永远不会被触及。

这在前一天运行良好,我所做的唯一更改是安装 PYCharm(我现在已经将其卸载)。

而如果我在没有调试器的情况下执行程序,那么它可以毫无问题地执行。

在此处输入图像描述

launch.json 截图如下:

VS已经更新:

在此处输入图像描述

在此处输入图像描述

Requirements.txt 截图:

在此处输入图像描述

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",
            "stopOnEntry": true,
            "justMyCode": false
        }
        
    ]
}

标签: pythonvisual-studio-codevscode-debugger

解决方案


这是VScode. 您可以尝试的一种解决方法是添加这样的requirements.txt文件:

jedi==0.15.1
parso==0.5.1
isort==4.3.21
ptvsd==5.0.0a5
pyparsing==2.4.0
six==1.12.0
packaging==19.2

并将其保存到

%USERPROFILE%/.vscode\extensions\ms-python.python-2019.10.41019\

windows

$HOME/.vscode/extensions/ms-python.python-2019.10.41019/

对于maclinux

如果这不起作用,请尝试更新VScode. 您可能有一个没有修复错误的过时版本。您也可以尝试将stopOnEntry和添加justMyCode到您的launch.json文件中:

"configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            // Add these lines
            "stopOnEntry": true
            "justMyCode": false

        },
}

您可能需要添加它,因为默认调试器将执行您的文件,直到它遇到异常(或您的程序退出)。


推荐阅读