You need to add C:\Python27 to your system PATH variable, not a new variable named "python".
Find the system PATH environment variable, and append to it a ; (which is the delimiter) and the path to the directory containing python.exe (e.g. C:\Python27). See below for exact steps.
The PATH environment variable lists all the locations that Windows (and cmd.exe) will check when given the name of a command, e.g. "python" (it also uses the PATHEXT variable for a list of executable file extensions to try). The first executable file it finds on the PATH with that name is the one it starts.
Note that after changing this variable, there is no need to restart Windows, but only new instances of cmd.exe will have the updated PATH. You can type set PATH at the command prompt to see what the current value is.
Exact steps for adding Python to the path on Windows 7+:
- Computer -> System Properties (or Win+Break) -> Advanced System Settings
- Click the
Environment variables...button (in the Advanced tab) - Edit PATH and append
;C:\Python27to the end (substitute your Python version) - Click OK. Note that changes to the PATH are only reflected in command prompts opened after the change took place.
You need to add C:\Python27 to your system PATH variable, not a new variable named "python".
Find the system PATH environment variable, and append to it a ; (which is the delimiter) and the path to the directory containing python.exe (e.g. C:\Python27). See below for exact steps.
The PATH environment variable lists all the locations that Windows (and cmd.exe) will check when given the name of a command, e.g. "python" (it also uses the PATHEXT variable for a list of executable file extensions to try). The first executable file it finds on the PATH with that name is the one it starts.
Note that after changing this variable, there is no need to restart Windows, but only new instances of cmd.exe will have the updated PATH. You can type set PATH at the command prompt to see what the current value is.
Exact steps for adding Python to the path on Windows 7+:
- Computer -> System Properties (or Win+Break) -> Advanced System Settings
- Click the
Environment variables...button (in the Advanced tab) - Edit PATH and append
;C:\Python27to the end (substitute your Python version) - Click OK. Note that changes to the PATH are only reflected in command prompts opened after the change took place.
Assuming you have Python2.7 installed
Goto the Start Menu
Right Click "Computer"
Select "Properties"
A dialog should pop up with a link on the left called "Advanced system settings". Click it.
In the System Properties dialog, click the button called "Environment Variables".
In the Environment Variables dialog look for "Path" under the System Variables window.
Add ";C:\Python27" to the end of it. The semicolon is the path separator on windows.
Click Ok and close the dialogs.
Now open up a new command prompt and type "python"
It should work.
How to run a python program using windows run?
Running a python script not in CMD
Python not found by command prompt
Best way to use python on windows 7?
Did you install it from here?
https://www.python.org/downloads/windows/
Which version did you install? How are you trying to use Python? The way it's usually done is to open a .py file in your favourite text editor or IDE then when you want to run it, most editors/IDEs have a button or keypress you can hit to execute the current file.
More on reddit.comGiven that you're most familiar with Unix, I'm not sure if you are comfortable with Regedit and the Windows registry.
So let's get you a simple well-regarded tool to handle this task without asking you to manually edit the Windows registry.
First download FileTypesMan from NirSoft. It's written by Nir Sofer, who is a well-known and trusted developer. It's not open-source (unfortunately), but Nir has been publishing free tools for over 15 years with an unblemished record.
Now follow these simple steps within FileTypesMan:
- Find the
.pyfile type in the top pane and click on it. - In the bottom pane, find the
openaction (Namecolumn) and double-click it. - In the ensuing dialog box, change the command line to
"C:\Windows\py.exe" "%1" - In that same dialog box, ensure the
Default Actioncheckbox is checked and theDisabledcheckbox is not checked, then click OK to close the dialog box.
Voilà. You're done.
You can now close FileTypesMan.
Depending on the installed version of Windows, you may need to restart the shell. If you don't know how to do that programmatically, just log off, and log back in. Or, if you prefer, reboot.
As Gerhard mentioned in the comments, there is a significant security risk to allowing scripts to run directly like this, but you mentioned you understand the risks and the tradeoffs are worth it to you. I simply recap those comments here in this answer to help people in the future in the event that the comments get deleted.
...I want to just type
"blah"to executeblah.py
- You can try:1. Add the path to the
Python.exebinary2. Add eXtensions
.pyand.pywto thePathExtvariable3. Run your files
> Your_py_Script > Your_pyw_Script
- How to set the
Pathand environment variables in Windows - What is the
PathExtEnvironment Variable in Windows?
I finished making a small program which opens a website and checks my ping speed for me. The problem is I don’t to open the IDE I’m using everytime I want to use the program. When I open windows run (using windows button + r) and type “pingTest.py” it opens my IDE rather than executing the script. I managed to accomplish just running the program before but I’m unable to recreate that. Let me know if I need to provide more information.
Any help would be appreciated.
So as it says, is there anything I can use to run python scripts that is not CMD. Something more, user friendly?
I am only asking because I have concluded that I am mentally incapable of using a terminal, and I need something simpler.