Here is the extension for python I used in the vs code: python extension.
When I use the debugging feature provided by the extension, it will hang in there and do no
In Visual Studio Code click the pick list to the right of the green arrow. Then select Python: Terminal (external). When you launch your script it will run in an external window and allow you to key in input.
Change the launch.json and put this into your java code
{
"type": "java",
"name": "Debug (Launch)",
"request": "launch",
"cwd": "${workspaceFolder}",
"console": "externalTerminal",
"stopOnEntry": false,
"mainClass": "",
"args": ""
}
The trick to getting this to work is on the extension's(Don Jayamanne's Python) wiki page. You have to include "externalConsole": true
setting in your launch.json
file's "name": "Python"
section.
The extension's wiki confirms that this does not work by default:
This allows for capturing of input from the console/terminal window applications, which isn't possible in the standard VSCode debugger.
Here are the steps to getting this to work:
.vscode
directory in what ever folder you have selected as your "Open Folder" in VS Code.pythonPath
parameter to the first configuration block. This is needed to have the debugger work at all.externalConsole
parameter to the same block. This is what is needed to have the debugger accept input. When you debug, a separate window will open outside of VS Code but works well otherwise. After you add both settings, the block should look something like this. I did not have to change anything else in the rest of the launch.json file.
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"program": "${file}",
"pythonPath": "C:/Users/igor/Documents/Tools/WinPython-32bit-3.4.3.7Slim/python-3.4.3/python.exe",
"externalConsole": true,
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
Most of the higher-rated, original answers are no longer valid, or unclear exactly what to set and how. See below for details how to set the "Console" option in launch.json
, and what all the options are.
You can choose either an internal or external terminal setting and have keyboard input work during debug. One option for output, the Debug Console, does not currently (Fall 2019) allow keyboard input to your program, although you can always use the debug console to enter live debug and code commands.
The steps to set the available options are below.
launch.json
file"console":
option to one of the settings described below
"console"
settings in launch.json
"console": "internalConsole"
"console": "integratedTerminal"
DEBUG CONSOLE
tab if you want to run command during debugging.
"console": "externalTerminal"
Press any key to continue...
prompt after your program terminates so that you can view/copy any output before it disappears.DEBUG CONSOLE
in VS Code when the code is paused to enter debug commands.The console
option could have any of these values: internalConsole, integratedTerminal, externalTerminal
.
Normally if you start the debugger and the program stops, it leaves the external terminal displaying a prompt Press Enter to continue . . .
to have access to any output of the program. If you accidentally have a syntax error the external terminal just closes not leaving any message.
When using the integratedTerminal
option, the terminal stays there and displays the error message.
While I do not know if this externalTerminal thing is a bug or not, the integratedTerminal option seems to work much better in this case.
The externalconsole
directive is deprecated. Use console
instead and indicate your preference for external this way:
"console": "externalTerminal"
The application output (and input) will go to a separate window so the VS Code debug console remains a pure python prompt where you can evaluate stuff during breakpoints.