I'm trying to run some Python files from command line, using PowerShell, but I'm really unfamiliar with the shell, and I've run into some issues trying to run python. I think there is some preparation process for python that I've missed, but I don't know what.
In trying to run Python through Powershell, I've tried installing Python 2.7 on my computer. While it changed the nature of the error message I was first receiving, it has otherwise not done much.
I've also tried doing some research to see what might be going wrong, personally, but I'm having some trouble finding an exact answer to my problem, and therefore figured I'd try asking, on here.
From what I've seen, online, I think this is the correct way to call and run a python file in Powershell. It's what I'm currently using:
PS C:\Users\nickd\documents\Coding\Comp_Sci_Class\Python\debugger> python my_test.py
This should run a program that tests whether or not a debugger is working. Instead, I get the following error message when I try and use the command 'python':
python : The term 'python' 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:1 + python my_test.py + ~~~~~~ + CategoryInfo : ObjectNotFound: (python:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
As such, I'm led to believe that there is some step in preparing Python for use on Windows Powershell that I'm just missing, but I'm not finding a clean cut answer for what that might be.
Could somebody please help me out, and describe what it is I might need to do? I know that what I'm missing is likely extremely simple, and I apologize upfront if this is a silly problem to have. That said, if somebody could point me in the right direction as to what I need to do, I'd be really grateful.
Powershell doesn't find where you have installed python. If you add the folder where python.exe is located to path then it will work. See here https://superuser.com/a/143121
You have to add location of
Python.exe to your environment variable..
Your path might be
Please follow the below steps :
1) Right Click on This PC (My Computer) and Select Properties ( Win Key + Pause key) 2) Click on Advance system setting from left pane 3) Click on Environment Variables... 4) select variable called "Path" from second list box 5) Click on Edit button below the same list box 6) Add python.exe full path ( do not include filename ) 7) close all dialogs by clicking OK 8) restart your powershell | ISE
Since Python 3.3, the PythonLauncher is installed with Python on Windows. It is py.exe and is already in the PATH (c:\windows).
py my_test.py. If you have multiple versions of Python installed,
py -3.6 (for example) will run Python 3.6.