How to run Python from Windows cmd

44,988

Solution 1

You need to modify the Windows %PATH% environment variable. Under My Computer ‣ Properties ‣ Advanced ‣ Environment Variables, you should modify the %PATH% variable to include your Python directory, i.e. C:\Python26.

See: http://docs.python.org/2/using/windows.html#excursus-setting-environment-variables

Solution 2

That means Python Path isn't declared. Try this:

cd --> to pacman.py dir
C:\PythonVersion\python.exe pacman.py

Solution 3

Try using this, dir C:\py*, this should give you a message like this "Volume in Drive C: Windows version--- Volume Serial number Directory of C: and a Path to Python, where it is installed on your computer", if you get this you are good to go...

Share:
44,988
user1210233
Author by

user1210233

Updated on January 27, 2020

Comments

  • user1210233
    user1210233 over 4 years

    I am trying to run a python program in Windows with a call like this:

    python pacman.py
    

    I have many such calls to the python program. I want to run it from windows command line. When I run this in Ubuntu it works well but when I try it in Windows, I get the following error:

    'python' is not recognized as an internal or external command, operable program or batch file.
    

    How can I run these python programs from Windows cmd?