VS Code debug console won't work with Python input()

1.2k views Asked by At

I have some simple code that works fine everywhere except the Debug Console on VS Code.

Here it is:

pounds = int(input("How much do you weigh in pounds? "))
kilos = pounds * 0.45359237
print("You weight " + str(kilos) + " kilograms.")

If you use the launch.json configuration of "console": "internalConsole",, then the output will go to the debug console, which doesn't work. If you do "console": "integratedTerminal", the output will work and it will go to the terminal, but, it will make a new debug console each time, and eventually it will stop working on the 33 time. I have the screenshot below. The error is not shown in the terminal, but in a pop-up. The error states:

The terminal process "C:\Program Files\Git\bin\bash.exe" terminated with exit code: 256.

So there are two problems:

  1. Debug console won't work with input()
  2. Terminal makes too many debug consoles, causing it to error.

I am confused as to how anyone uses python on VS code, because I can't even get it to work. I guess I can delete the consoles each time it reaches 33, but that seems inefficient and not how VS Code was intended to be used.

screenshot: enter image description here

1

There are 1 answers

0
Jill Cheng On
  1. According to the information you provided, when I use "console": "integratedTerminal" in VSCode, the results will be executed sequentially in the same terminal:

    enter image description here

  2. When using "internalConsole", the result will not be executed normally, because currently the debugging console in VSCode is only used to display output.

  3. In addition, we can also use "console": "externalTerminal", which can also accept input:

    enter image description here

Reference: console in VSCode.