Installing and Using Python

To see if your computer has Python installed, try this:

  1. On a Windows machine:

    In your My Documents folder (or Desktop), use Notepad to make a file named and place in the file the single line,

    Then, try double clicking on the file's icon to start the program. If it displays a new command window and prints hello, you have it.

    Or, from the Start menu, use Search to search all files and folders for the file, python.exe. If the search command finds it, it will show you where.

  2. On a Linux machine (or MacOS that lets you start a Unix command window): Type the command, which python

    If Python exists, you will see the directory path to it.

Important: your computer must have Python version 2.4 or newer but not Python 3.0 or newer (which is a brand-new release that is incompatible with all previous versions, alas).

Installing Python if you do not have it

If you must install Python, you will find it easy. Go to, click on ``Download Now'', fill in your name and address, then download and install Python Version 2.6; it's available for Windows, Mac OS/X, Linux, etc.

Try your implementation by using Notepad to make a file named and place in the file the single line,

Then, try double clicking on the file's icon to start the program. If it starts and prints hello, you are good to go. (Or, try starting the program from a command window, like this: python

Using a command window to develop and test programs

If your Python program contains an embedded error, then it is disaster to test it by double-clicking on its icon --- the program literally explodes its output window! You must test an insecure Python program by starting it within a command window. If the executing program generates an error, the error message displays in the command window in which you activated it.

If you are a Linux hacker, starting a program by typing a command in a command window is old news to you. (So, just do it.) For this reason, the remainder of this note is oriented to Windows users who have less experience with command windows and environment variables:

Say that you have installed Python on your computer. The standard way to use it to write and test programs is with a command window. (After you have the program operating correctly, then you can execute it by double-clicking on the program's icon.)

So, it is important to learn how to start Python from a command window. First, try this experiement:

  1. open a command window
  2. type

    If you see

    Python 2.6 (#1, May 18 2006, 07:40:45)
    Type "help", "copyright", "credits" or "license" for more information.
    Then your computer is ready to use Python and you need not read the rest of this note. But if you see the message,
    'python' is not recognized as an internal or external command,
    operable program or batch file.
    then you must tell Windows XP where to find the Python software that you installed.

Finding Python

When you installed Python, you told the installer program to place it somewhere on your disk. It is probably the case that there is a folder named C:\Python26, and within that folder, there is a program named python.exe. The path to Python is therefore C:\Python26. (Another possibility is that Python is installed at C:\Program Files\Python26.)

If you have no idea where Python was installed on your computer, you must search for it:

  1. Press Start in the lower left corner of your display; press Search; in the search window, press all files and folders; in the top textline that appears, type python.exe; press the Search button.
  2. After several minutes, the folder where Python is installed will be listed --- that folder name is the path to Python.

Now that you know the path to Python (e.g., C:\Python26), go look for it: Open a file window, find the folder, and open it --- is python.exe inside the folder? It should be! If not, double-check the path information --- you must find the location of the python.exe program to continue. Keep looking till you find it!

Now you are ready to use a command window to execute Python.

The simple way

To use Python within a command window, do this: Open a new command window and type the set path command:

set path=C:\Python26
(Use the path you just discovered!) This tells the command window to find the Python interpreter, python.exe, in the folder, C:\Python26.

Now, type

You should see the start-up message for the Python interpreter. Success! Now, exit the interpreter. (Type exit) (If you do not see the start-up message, double-check the path to python.exe!)

Now you are ready to use the same command window to cd to the folder where your Python programs reside, and you can use the Python interpreter to execute them.

The permanent way to set the path

Each time you open a command window, you must type the set path command to set the path to Python. It is a bit annoying to do this every time you open a command window, and there is a clever repair --- you can reset permanently the value of Windows's PATH variable so that Windows knows once and for all the path to Python. Here is what you must do on Windows XP to reset the PATH variable:

  1. press Start
  2. select Control Panel
  3. On the Control Panel window, in the left column, press Switch to classic view (If you don't see this text, go to the next step below.)
  4. Double click on the icon for System
  5. In the System window, click on Advanced
  6. Click on the button Environment Variables
  7. In the new window, scroll until you see the variable, Path; click on it
  8. Press Edit
  9. Carefully use the right arrow button to move to the end of the long sequence of folder names. At the very end, without including any extra blanks, type this:
Close all the windows and restart the computer. Now, when you open a command window, you can type python and the path is already known by WindowsXP.

If you use Windows Vista, you must still find your way to the Environment Variables table within your computer. Use your Help facility to search for information about Environment Variable.