1

Hi I often use Power Shell on Windows 7

I'm often typing commands like

C:\Python26\ python.exe example.py

C:\Python26\scripts\ pip.exe install examplePy

C:\Python26\scripts\ easy_install.exe examplePy

I would like to simply type (as I do on Linux)

python example.py

easy_install examplePy

pip install examplePy

How do I go on about it?

Help would be very much appreciated.

4 Answers 4

4

You'll need to set the PATH. There are several paths, and in the end they (usually) get merged in to one.

PATH entries are delimited by semicolon (;).

Two are managed by Windows:

  • The system path. Affects all users on the computer.

  • The user path. Affects all programs you run under your user account.

Under Windows 7, the first two are easy to find: open the start menu and type PATH.

alt text

Under older Windows version, you'll need to find the Environment Variables settings. There are several ways to get to them, and it varies by Windows version, but the other answers are valid.

alt text

A third is process-specific:

  • The current process path. Affects the current process and any new processes it creates.

If you're in a PowerShell session, the PATH is visible as $env:PATH. To add something, use +=. I'd recommend using env. vars. instead of hard paths where possible.

PS > $env:PATH += ";C:\Python26\"
PS > $env:PATH += ";$($env:ProgramFiles)\Bar\"

Normally you'd do this in your profile. The path can be found at $profile:

PS > notepad $PROFILE

1
  • Additional tip: Powershell comes with an Integrated Script Editor, which supports Powershell syntax highlighting. It is nicer to edit Powershell profile with it. You can use it like this: PS > powershell_ise $profile
    – Mr Alpha
    Commented Dec 28, 2011 at 13:43
4

You can set the system variable PATH. Here you can store several directories which will be searched when you enter a command on the command line and this command is not found in the current directory.

Go to system control and search for "path" in the search box.

3
  • Thank you very much Martin. But I noticed I have to set these every time I reboot. :(
    – RadiantHex
    Commented Jan 23, 2010 at 19:09
  • @RadientHex - you need to update the PATH in the registry as per @Lukas's answer. Just updating the PATH in the current command window will work, but the changes are local to that window.
    – ChrisF
    Commented Jan 23, 2010 at 19:15
  • actually, I meant this, too. I only didn't know the exact english names in the system control, because I'm using German Windows :)
    – Martin
    Commented Jan 24, 2010 at 11:51
3

Add folders C:\Python26\ and C:\Python26\scripts to path. Go to system administration -> Environment -> Locate path and add your folders. Do not delete anything.

1
  • 1
    except Quicktime. you can remove Quicktime from your path and your computer will survive. i promise. Commented Jan 23, 2010 at 19:21
0

Using setx can be easy here:

setx PATH "%PATH%;Folder path to add"

then restart CMD.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .