Visual Studio Code Terminal keeps running Python script in Powershell Visual Studio Code Terminal keeps running Python script in Powershell powershell powershell

Visual Studio Code Terminal keeps running Python script in Powershell


There is nothing wrong with your setup. It looks you miss basic understanding of different ways to execute python code.

VS Code has integrated terminal. From there You can run your python script i.e. file with py extension same as you are on terminal/cmd/powershell. That is common way to write and execute code.

When you type python and hit enter you start python interactive shell. That is when you get >>> prompt. Your python interpreter evaluate and execute each line as you type in and hit enter. Same will happen if you type in python in cmd/powershell outside VS Code. Interactive mode is used more or less to experiment, test simple ideas, simple code examples, etc. but the code you type in is lost once you exit the interactive mode by >>>exit().

for further reference you may check


After reading the documentation above, I also had a similar problem after running scripts. I think that VSC is exiting out of python after running a script and requires starting up the python terminal again. I wonder if VSC can default to python after running a script instead of exiting out to powershell.


I figured out what the issue was here. Visual code thought Python was installed in the directory that my .py files are saved in as opposed to the actual location under program files. The path had to be edited under settings.