6

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?

user1210233
  • 2,730
  • 5
  • 24
  • 31
  • 2
    http://docs.python.org/2/faq/windows.html#how-do-i-run-a-python-program-under-windows – Blender Mar 02 '13 at 04:38
  • 1
    Python does not come pre-installed on Windows like it does with Ubuntu, so make sure you have actually [installed python](http://www.python.org/getit/) first. – grc Mar 02 '13 at 04:44
  • Python has been installed, I can press Run from IDLE and it runs. – user1210233 Mar 02 '13 at 05:38

4 Answers4

8

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

Matt
  • 313
  • 1
  • 6
1

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

cd --> to pacman.py dir
C:\PythonVersion\python.exe pacman.py
Norton Penguinion
  • 161
  • 2
  • 3
  • 6
1

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...

0

Simply calling pacman.py from the command line is enough if your windows is set to open .py files with python.exe. Which is easily done through the file manager. (And gets set by default when installing python.)

Wolfer
  • 891
  • 2
  • 12
  • 21