Visual Studio Code Terminal keeps running Python script in Powershell


I recently installed both Python and Visual Studio Code. After taking an intro class I wrote a basic script and ran it in Visual Studio Code. That’s when I noticed a problem with the way Python is setup in my Visual Studio code.
When I start Visual Studio Code and open a python file, the Terminal defaults to “C:\Users\my_name\Documents Python” (this is the folder my python files are stored in). From what I understand, when you’re in Python, the prompt should be “>>>”. I am able to run my script but i cannot run any other Python code (ie something as simple as z = 5) in the terminal. If I type in “Python”, I am prompted with “>>>” but can no longer run my script.

I thought this was an installation issue so i uninstalled and reinstalled both Python and Visual but the problem persists.

I tried adding the Python file path to where the program is installed to the windows environment under system settings and also clicked “Add to Path” when reinstalling Python but none of these solutions seemed to work.

when basic python code (ie z=5) doesn’t seem to work but the script runs fine I get the error message below:

Below is the error message I get after I switch to python and try running my script


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.


Visual Studio Code Terminal keeps running Python script in Powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply