Sanskar Kumar
Sanskar Kumar

Reputation: 473

The output when I run code in VSCode gets displayed in the terminal window instead of the output window

I tried some of the solutions posted earlier in similar questions but none of them seem to work for me. My code is in Python 3.8 and I am using the latest version of VSCode. Thanks.

Upvotes: 0

Views: 11090

Answers (3)

LearnUseZone
LearnUseZone

Reputation: 159

Install "Code Runner" extension.

  • VS Code -> Extensions (Ctrl+Shift+X) in the most left panel -> text box "Search Extensions in Marketplace" -> Code Runner -> Install

Setting up Code Runner

  • VS Code -> File -> Preferences -> Settings (Ctrl+,) -> text box "Search settings" -> Code Runner -> ensure that checkbox for "Code-runner: Run In Terminal" is unchecked.

Running Python Scripts

  • Prepare a Python code you want to run -> Press Ctrl+Alt+N to run the code via Code Runner.
  • If the shortcut Ctrl+Alt+N is already taken e.g. by another software, you can change the shortcut
    • File -> Preferences -> Keyboard Shortcuts (Ctrl+K Ctrl+S) -> search: Code Runner -> Run Code

If you want to clear previous output (from OUTPUT window) -> File -> Preferences -> Settings (Ctrl+,) -> text box "Search settings" -> Code Runner -> ensure that checkbox for "Code-runner: Clear Previous Output" is checked.

Upvotes: 0

Biswajit Deb
Biswajit Deb

Reputation: 11

Make sure you've the code runner extension installed. If yes then,enter image description here Go to settings , 1.search Terminal 2. scroll to the last line 3. uncheck code run in terminal

Upvotes: 1

Jill Cheng
Jill Cheng

Reputation: 10372

When running python code in VS Code, it executes the running command in the VS Code internal terminal ( TERMINAL ) by default. It is a terminal that allows user interaction, but "OUTPUT" is an output terminal, which cannot receive user input.

For how to make the output display in "OUTPUT" in VS Code:

Please use the "Code Runner" extension in VS Code, which uses "OUTPUT" by default:

enter image description here

In addition, if you want to use relatively clean output, you could also use "DEBUG CONSOLE".

Please use in "launch.json": "console": "internalConsole", then click F5 to debug the code:

enter image description here

Upvotes: 1

Related Questions