Last
updated: Sunday 28th March 2010, 6:37 PT by AD
How to install and run the Python interpreter
Introduction
This web
page explains how to download, install and run the free Python interpreter.
After
following the instructions in this document you will be able to run single line
Python commands (statements).
The CSCI120 and the CSCI165 course resource web
pages contain instructions for the use of various editors which allow you to
store several Python statements in one file to be executed in sequence by the
Python interpreter... How
to install Python and run Python Programs using the IDLE editor
How to install and run the Python interpreter
to run single Python commands
1. Go to the Python web site
In the
address box of your Internet browser, type in the following:
You will
see the following screen:

2. Download the Python software
At the
time of writing this document the current version of the Python interpreter
software is version 2.3.4. Newer versions will be released in the future. Newer
versions will be backward compatible - which means that if you write
Python programs using version 2.3.4, they should still run using future
versions of the Python interpreter. You should always download the latest
version of the software as it will contain the latest features and bug fixes.
Click on
the 'Download' link on Python's home page, which is located at the top centre
of the page. You should then see the following
screen:

Click on
the link for Python 2.3.4. You will then see this page:

If you're using a Microsoft Windows
operating system, click on the link to the file: Python-2.3.4.exe (under the
heading Download the release).
If you're using any other operating
system, scroll down under the heading Download
the release for further instructions.
The remainder of this document
assumes you're using a Windows operating system. This document is specific to
Windows 98, but other Windows operating systems operate in a very similar
manner.
You will then see this screen:

Click on the Open button to start
the download.

When download of Python-2.3.4.exe is
complete, run the file (double click on the file name) and follow the friendly instructions
on the screen to complete the installation. Choose the default settings.
If you chose the default settings
during installation, the Python software will be installed to the following
folder:
C:\Python23
The python interpreter is file:
C:\Python23\python.exe
3. Run the Python interpreter
Please note: the screen shots shown
are generated from a computer running the Windows 98 operating system. If you
have another version of Windows the screens may look slightly different, but
the procedures you should follow are the same.
You can run the Python interpreter
in a number of ways:
Running Python - Method 1
On your desktop, click on the Start button, then
click on Run .

In the Run window, enter the
following text in the text box, then click on the OK button.
C:\Python23\python.exe

You will then see Python running in
an MSDOS window (DOS shell):

You will see a few lines of
information followed by the Python prompt >>>. A prompt is simply the
location where instructions are typed in (at the shell command line).
After typing in a Python statement
at the prompt, you must press the Enter key (also known as the Return key) on
your keyboard.
At the >>> prompt, try
typing in the following simple Python statement:
print "Hello World!" (then press the Enter key).
Python responds by printing the text
"Hello World!" (without the quotes).
If you've got this far, you know
that Python has been installed correctly!

Notice that after Python interprets
and executes your command, the prompt returns ready for the next command
(Python statement). When running in this manner the Python interpreter is said
to be in the interactive mode, and will continue in this mode
indefinitely until you issue the command to quit.
To exit from the Python interpreter
you must hold down the Ctrl keyboard key and press the Z key at the same time
(Ctrl-Z). (Different operating systems may require a different key sequence,
e.g. Ctrl-C).
Running Python - Method 2
On your desktop, click on the Start button, then
click on Programs , then Python
2.3.4 , then select Python (command line) from the list of options.


Notice that the Python interpreter
is running in exactly the same DOS shell as shown in Method 1 above. You may
follow the same instructions for using the interpreter as described for Method
1.
Running Python - Method 3
In the third method of running the
python interpreter, you execute the interpreter by typing its file name at an MSDOS
shell command line. From the desktop, click on the Start button, then
click on Programs , then MS-DOS
Prompt . (In other versions of Windows, the MS-DOS
prompt may have an alternative name, eg DOS Shell, Command shell, etc.)


Please note, other operating systems
may default to a different folder than C:\WINDOWS. Notice that the prompt for
MS-DOS is a single right arrow symbol >. The prompt for the Python
interpreter is >>>.
Then type in the following text at
the MS-DOS prompt, and press the Enter key to run the Python interpreter:
c:\python23\python.exe


The screen above shows the Python
interpreter running in interactive mode. See Running Python - Method 1 for
an explanation of interactive mode and instructions on the use of the Python
interpreter with single Python commands. As explained earlier, to exit from the
Python interpreter you must hold down the Ctrl keyboard key and press
the Z key at the same time. (Operating systems other than Windows may
require a different key sequence, e.g. Ctrl-C).
If you run Python from an MS-DOS
Prompt shell, exiting from Python returns you to the MS-DOS Prompt shell. To
close the DOS shell and return to Windows, you must exit the MS-DOS Prompt
environment by typing exit at the command prompt, then press
the Enter key. An example of this is shown in the screen below.

How to install Python and
run Python Programs using the IDLE editor