How to fix Python error, The term '.../python.exe' is not recognized as the name of a cmdlet, function, script file, or operable program, in VS Code?

LouisAden Capellupo louisadencap at yahoo.com
Tue Oct 11 19:40:31 EDT 2022


     Hi! I've just downloaded and installed Python 3.10.7 (64-bit) for Windows 10 from python.org. I'm quite new but, I've already downloaded and installed Visual Studio Code as well. I have included the two paths for python under User Variables. C:\Users\It'sMeLil'Loui\AppData\Local\Programs\Python\Python310\Scripts\, and C:\Users\It'sMeLil'Loui\AppData\Local\Programs\Python\Python310\. I verified that python is recognized in the Command Prompt and PowerShell and installed the necessary extensions for python in Visual Studio Code. I created a test python file in the directory of D:\Projects\Python\Test\HelloWorld.py, and opened it in Visual Studio Code. I also restarted my laptop after all of this. Under the arrow used to run the code, I clicked "Run Code" (since I have Code Runner by Jun Han installed), and it worked just fine, displaying the output in the terminal.

Code:

print("Hello, world.")
input("Press Enter to continue...")

Output in Terminal when using Code Runner:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS D:\Projects\Python\Test> python -u "d:\Projects\Python\Test\HelloWorld.py"
Hello, world.
Press Enter to continue...
PS D:\Projects\Python\Test> 
However, under the arrow to run code, when I click "Run Python File", I get this error message:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Output in Terminal when normally running it:

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS D:\Projects\Python\Test> & C:/Users/It'sMeLil'Loui/AppData/Local/Programs/Python/Python310/python.exe d:/Projects/Python/Test/HelloWorld.py
& : The term 'C:/Users/ItsMeLilLoui/AppData/Local/Programs/Python/Python310/python.exe' is not recognized as the name of a cmdlet, function, script 
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:3
+ & C:/Users/It'sMeLil'Loui/AppData/Local/Programs/Python/Python310/pyt ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:/Users/ItsMeL...n310/python.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS D:\Projects\Python\Test>

     So basically, I get, "The term '...\python.exe' is not recognized as the name of a cmdlet, function, script, file, or operable program... At line: 1 char: 3." It works the first way I showed with Code Runner, but the second or original way doesn't work. What if I don't want to use Code Runner? Any help in fixing this problem would be greatly appreciated. Sorry if certain things are unclear as this is my first time using Python.

Thanks, 
LouisAden


Sent from Mail for Windows



More information about the Python-list mailing list