I just downloaded and installed Python 2.7.2 to my laptop and I am trying to run some sample programs. My laptop is running Windows XP.
When I open a cmd
window and type python
I get:
'python' is not recognized as an internal or external command, operable program or batch file.
I am not a Windows person (mostly mainframes). However I am guessing that there is some command that I need to execute to define python as a command. Can anyone tell me what that command is?
The installer placed Python at C:\Python27\
.
To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World!
You need to add the python executable path to your Window's PATH variable.
c:\Python27\
). Each different directory is separated with a semicolon. (Note: do not put spaces between elements in the PATH
. Your addition to the PATH
should read ;c:\Python27
NOT ; C\Python27
)cmd.exe
should be sufficient.This is because the Python exec are not in the search path of your operating system. In windows, start CMD. Type in
setx PATH PythonPath
where PythonPath is usually C:\Python27
or C:\Python33
or C:\Users\<Your User Name>\AppData\Local\Programs\Python\Python37
depending on your Python version. After restarting the CMD, you should get see outcomes when typing
Python --version
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With