python executable path to your Window’s PATH variable.
- From the desktop, right-click My Computer and click Properties.
- In the System Properties window, click on the Advanced tab.
- In the Advanced section, click the Environment Variables button.
- Highlight the Path variable in the Systems Variable section and click the Edit button.
- Add the path of your python executable(
c:\Python27\). Each different directory is separated with a semicolon. (Note: do not put spaces between elements in the
PATH. Your addition to the
- Apply the changes. You might need to restart your system, though simply restarting
cmd.exeshould be sufficient.
- Launch cmd and try again. It should work.
Start Menu and right click My Computer. Click on Advanced System Settings.
Then click on Environment Variables. This is where we can add Python to the PATH environmental variable.
PATH variable and click Edit. You want to add Python to this PATH variable by adding ;C:\Python27 to the end of that string (or whatever the path to your Python installation is).
Save your changes!
So what exactly is happening here?
When you type in
python in a command prompt, Windows will use the
PATH environmental variable to get a list of directories to go looking for the python.exe file. Before you followed the steps here, it couldn’t find the python.exe file, hence the error.
Now that the
PATH variable is set, when you execute
python via the Windows console, you’ll see a familiar programming prompt.
Python running on Windows!