2

I am using the Remote SSH extension for VSCode. Whenever I try to run a Python file in the Python terminal using the Run Python File in Terminal command, while the terminal is already executing another python program, VSCode tries to execute the new program in the same Python terminal, instead of opening a new terminal. Is there a way to execute each python program in a new terminal so that multiple programs can run simultaneously?

Edit: Tried to open a new Python terminal explicitly, but still, the Run Python File in Terminal is always routed to the first terminal. If I run the Python program explicitly in the new terminal by typing python my_prog.py it works, but I am looking for an interactive way.

4
  • Tried to set in launch.json "console": "externalTerminal" as you suggested, but actually, it had no effect. Commented Mar 15, 2021 at 12:24
  • Did you click F5 to debug the code after setting "launch.json"? Commented Mar 16, 2021 at 1:37
  • I don't want to run in debug mode since this is much slower. Also this doesn't work too as I get can't find terminal application 'xterm' on F5 Commented Mar 17, 2021 at 15:50
  • -At present, in VS Code, in addition to manually inputting execution commands, debugging code can be implemented in multiple terminals to run the code. If F5 does not work, please try to click the "Start Debugging" button of VS Code. Commented Mar 18, 2021 at 1:16

2 Answers 2

3

In VS Code, the command "Run Python File in Terminal" is executed by default in a "default" "Terminal", which avoids the impact of runtime confusion and reduces the time to find python and file paths at runtime.

If synchronization is required, VS Code currently does not support running two or more terminals simultaneously. You can refer to this link: Can VSCode automatically run python scripts in two or more terminals at the same time?

If you don’t require synchronization, only need to be in a new independent terminal every time the code is executed, you can set it in "launch.json": "console": "externalTerminal",

Then click Ctrl+F5 to run the code or click F5 to debug the code:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

According to the discussion link Can VSCode automatically run python scripts in two or more terminals at the same time? provided by @jill-cheng, since 9th May 2023 it is possible. The "Run Python in Dedicated Terminal" option has been added at least in the pre-released version.

Image showing the newly added option "Run Python in Dedicated Terminal"

2 Comments

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.