Darka
Darka

Reputation: 43

No output in Output Panel when running code - Python on VSCode

new to Python and StackOverflow. Apologies if I miss any formalities.

I just created a one-line program to print Hello World but every time I run the program (using F5 or by going to Run->Start Debugging) the program runs and the panel at the bottom automatically switches to the Terminal window and the output gets displayed there and not in the Debug window. (Picture 1)

There are a lot of other things that get printed in the Terminal window which is why I want only the output to be printed in the Debug window. Also, that is how it is shown in the video of the course that I am doing (Picture 2).

print("Hello World")

My Debug window with no output of the program

Screenshot of the Course Video Output as it appears on the Debug Window

Upvotes: 3

Views: 16084

Answers (1)

Jill Cheng
Jill Cheng

Reputation: 10372

If you want to display the results in the debug console, you could open file launch.json in folder .vscode and add this setting: "console": "internalConsole",. (or open the setting pattern next to the debug button to open launch.json file. )

enter image description here

This is the complete content of my launch.json file:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Current File",
      "type": "python",
      "request": "launch",
      "program": "${file}",
      "console": "internalConsole",        
    }
  ]
}

Then, through the test, the result is displayed in the debug console. like this:

enter image description here

Reference: Python debug configurations in VSCode.

Upvotes: 6

Related Questions