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 Python Terminal
Running Python Programs from a Terminal
what is the simplest way to run a a python script?
Running python script works, but does not show terminal in Windows
Given 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've new to python and trying to learn the computer language to experiment and hopefully be good enough to get a job. I bought "Python Crash Course" 2nd edition by Eric Matthes and have been researching youtube videos on the language to learn more about the program. I don't know if its just my computer or I didn't set it up right but its impossible for me to open or run a python program from my terminal. I always get hit with the "The system cannot find the path specified" whenever I try and it's becoming really frustrating. I watched a couple videos online but nothing seems to work. How do i fix this little issue?