Search code examples
pythonpowershellvisual-studio-codevscode-debugger

VSCode python debugging doesn't work with powershell


I am using vscode on windows, I have changed the default terminal to PowerShell and after that the debugging stopped working. When I start the debugger, it just exists after a second or two without stopping at breakpoints or errors.

My user settings that I've changed:

"terminal.external.windowsExec": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
    "terminal.integrated.defaultProfile.windows": "PowerShell"

and my debug configuration looks like this:

{
    // 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": "script",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "cwd": "${workspaceFolder}",
            "console": "integratedTerminal",
            "justMyCode": false
        }
    ]
}

It used to work before, when the default shell was cmd. Does anyone know how to configure debugger such that it works with PS as the default shell?


Solution

  • Have you set the "console": "externalTerminal"? The VSCode does not support PowerShell as the external terminal when debugging. it is designed only for cmd.

    You can try to set the external terminal to windows terminal through "terminal.external.windowsExec": "wt -p cmd cmd",. And when you set it to "terminal.external.windowsExec": "wt -p powershell powershell", you can get the exact problem.

    You can refer to this page for more details. And I have submitted an issue on GitHub.