views:

34

answers:

1

Hi, i've got a problem when i'm doing dev

I managed to use python manage.py runserver in a CMD shell but the system cant find python

How could I add python to the system dependency to make the commandline work?

+2  A: 

There are two basic ways you can do this in Windows.

Setting the PATH in the cmd shell

The first way is only local to the CMD shell you are currently in, and will have to be done again if you opened a new shell.

You can set your PATH to include the directory where python.exe is located.

In your CMD shell you can do:

set PATH=%PATH%;C:\path\to\python\install

So if Python was installed in C:\Python27, you would do this:

set PATH=%PATH%;C:\Python27

Setting the environment for your user throughout Windows

Alternatively, you can set your PATH permanently by changing the environment variable in Windows. Setting this will affect the rest of your Windows environment.

  1. Right click "My Computer"
  2. Select "Properties"
  3. Click the "Advanced" tab in the new window.
  4. Click on the "Environment Variables" button.
  5. Edit the variable named PATH

Information about doing the latter at Microsoft: http://support.microsoft.com/kb/310519

birryree
I think you under emphasized that if you use the former option, you have to do it *every* time. At least, that's how mine works.
John
Yes, I should add that the first choice is transient. Thanks!
birryree
I also append `.PY;.PYW` to my PATHEXT environment variable so I don't have to type "python" before the script name every time I want to execute one. Windows knows how to launch Python files through the file associations set-up by installing Python. See fuller explanation [here](http://www.voidspace.org.uk/python/articles/command_line.shtml#pathext).
martineau