Django/Python on Windows — Setting PATH Environment Variable

What is the PATH?

The PATH environment variable is in general a list of directories that the operating system will search through when programs attempt to execute a command.

For example, say we go into the windows command prompt or Ubuntu’s bash shell and type in “foobar” – the operating system will attempt to locate an executable (program) named “foobar” in the folders listed in the PATH. Replace “foobar” with “python” or “django-admin.py” and you start to understand why this is useful.

How do we set the PATH?

To set the PATH on Vista or Windows 7:

Push the windows button and type “environment variable” on the search bar and select “Edit environment variables for your account”.

Non Vista/Windows 7 users just right click on My Computer, go to Properties, click Advanced Properties, then the Environment Variables button to get to the same place.

In the Environment Variables screen, look for the “Path” variable under the “System Variables” section on the bottom. If it doesn’t exist, just make a new one.

Edit or enter in folder paths separated by ; — Append whatever you like to the string ending with a “;”

Do not delete the default path – append to it.

Path2;Path2;Path3;

Done!

19 Comments

  1. Yuji says:

    This post seems often searched for.. is the question not answered? :3

  2. Shaon Bhuiyan says:

    Thank you Yuji, I was looking for a way to do this.

  3. Pingback: gcc issue
  4. rumman says:

    I tried this but it doesn’t work.Can any one help me ?

    C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\Common Files\ArcSoft\Bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\DW WLAN Card;C:\Program Files\Windows Live\Shared;

    E:\install soft\Python\Python install\python.exe

    1. Yuji says:

      Try adding E:\install soft\Python\Python install\; to your PATH

      1. rumman says:

        added that and tried to test it in cmd , it shows this

        C:\Users\BDR-User>python
        ‘python’ is not recognized as an internal or external command,
        operable program or batch file.

    2. Yuji says:

      Yeah, if you add the parent directory to the PATH, and restart cmd, typing python should launch python.exe. Did you restart?

      1. rumman says:

        Hey , yuji thanks for your help I was able to add the path, unfortunately I was trying to add the path in another directory but i installed in some other directory, once i tried in the correct directory the problem was solved. Thanks again ๐Ÿ™‚

  5. Curtis says:

    Anyone interested in modifying the PATH or any other environment variable in Windows should check out “Rapid Environment Editor”.

  6. 0cool says:

    I did that but It is showing an error!
    but when I set my command prompt to python dir .. its working!

  7. Bobby Ong says:

    Thank you very much in explaining how to append Path. I didnt know I can set up multiple paths. That helps my Python and Django installations now. Cheers!!!

  8. Paul Lee says:

    I don’t understand what the path needs to be set to. Also I don’t have an option of editing the path because the edit button is greyed out. Thanks for the help but I’m still stuck : (

    1. Yuji says:

      The path needs to be set to the directory of any executable scripts you want access to from the command line. Say you have a script foo.py – if you put the directory it’s in into the path, then you can execute foo from any command line.

      If you can’t edit it – then that’s a different problem. Do you need admin rights or something?

    2. CCC says:

      I had the same problem, but there’s another way to get there. On your desktop, right-click My Computer. (If you don’t have that icon on your desktop, go to the Desktop via Windows Explorer.) Select Properties. Then click Advanced System Settings on the left, and then click the Environment Variables button at the bottom. Hopefully you’ve figured all that out by now, and this comment will just be useful to the next person to come along.

  9. BB says:

    Thank you! Works like charm! I did need to close the cmd and re-open it!

  10. PrimHel says:

    This is exactly what I was looking for, however I can’t access my system variables, only the user variables (I have an admin account on my windows 7). Anybody got an idea why? And how I can get access?

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s