Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a Python terminal vs. a bash terminal in VS Code?

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

like image 576
JohnM Avatar asked Aug 04 '26 03:08

JohnM


1 Answers

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.

like image 94
JohnM Avatar answered Aug 05 '26 17:08

JohnM