3

I'm often in VS Code writing a .py file, with a python environment chosen. The integrated bash terminal is enabled by default. In the command window, I have the option to choose "Python: create terminal". The terminals seems the same to me. What are the differences?

More info: The terminal is not interactive at all. It looks and acts just like the bash terminal from what I can tell. Typing a Python command like "import re" results in the same message as a bash terminal in vs code (picture below)

bash

python

1
  • The "Python terminal" is likely referring to a Python interpreter running in interactive mode, right? Commented Feb 22, 2020 at 2:12

2 Answers 2

2

There is at least one difference. Starting a new bash terminal in VS Code will open with your system's existing python environment as active (the one seen in a new terminal outside VS Code). Creating a terminal with the "Python: create terminal" command in VS Code opens an integrated terminal with the same active environment used by the interpreter.

For instance, if you are in this state with m5 as the interpreter environment in VSCode:

# conda environments:
#
base                  *  /home/jpm/miniconda3
m5                      /home/jpm/miniconda3/envs/m5

VsCode will open a regular bash shell with 'base' active . VsCode will open a Python shell with 'm5' active. Behavior with venv and conda environments is similar.

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

Comments

1

If you mean clicking right click and run selection/line in python terminal,

what that does is writes the command 'python' in terminal like you would, and it becomes a python command line, where you can type python commands that you would write in a script file. So you can write import {package} and it would import it. As opposed to the bash terminal, which is just a normal terminal embedded in VSCode

Comments

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.