Chapter 2. Python Installation
Downloading, Installing and Upgrading Python
This chapter is becoming less and less relevant as Python comes
pre-installed with most Linux-based operating systems. Consequently, the
most interesting part of this chapter is the Windows Installation,
where we describe downloading and installing Python on Windows.
Python runs on a wide, wide variety of platforms. If your
particular operating system isn't described here, refer to www.python.org/community
for more information.
Mac OS developers will find it simplest to upgrade to Leopard (Max
OS 10.5), since it has Python 2.5.1 included. This installation includes
the complete suite of tools, but doesn't include a clever Applications
icon for launching IDLE. You can make this icon yourself using
Applescript. If, for some reason, installiung Leopard is undesirable,
you'll need to do an install or upgrade. We'll cover a Mac OS
installation in Macintosh Installation.
For other GNU/Linux developers, you'll find that Python is
generally included in most distributions. In the unlikely event that you
have an old distribution and can't upgrade, we'll present some
alternatives that should cover the most common situations.
The goal of installation is to get the Python interpreter and
associated libraries. Windows users will get a program called
python.exe. Linux and MacOS users will get the
Python interpreter, a program named
In addition to the libraries and the interpreter, your Python
installation comes with a tutorial document on Python that will step you
through a number of quick examples. For newbies, this provides an
additional point of view that you may find helpful. You may also want to
refer to the official Beginner's Guide
In some circumstances, your Windows environment may require
administrator privilege. The details are beyond the scope of this book. If
you can install software on your PC, then you have administrator privileges.
In a corporate or academic environment, someone else may be the
administrator for your PC.
The Windows installation of Python has three broad steps.
- Pre-installation: make backups and download the installation
- Installation: install Python.
- Post-installation: check to be sure everything
We'll go through each of these in detail.
Backup. Before installing software, back up your computer. I strongly
recommend that you get a tool like Norton's
Ghost™. This product will create a CD that you
can use to reconstruct the operating system on your PC in case something
goes wrong. It is difficult to undo an installation in Windows, and get
your computer back the way it was before you started.
I've never had a single problem installing Python. I've worked with
a number of people, however, who either have bad luck or don't read
carefully and have managed to corrupt their Windows installation by
downloading and installing software. While Python is safe, stable,
reliable, virus-free, and well-respected, you may be someone with bad luck
who has a problem. Often the problem already existed on your PC and
installing Python was the straw that broke the camel's back. A backup is
You should also have a folder for saving your downloads. You can
create a folder in
My Documents called
downloads. I suggest that you keep all of your
various downloaded tools and utilities in this folder for two reasons. If
you need to reinstall your software, you know exactly what you downloaded.
When you get a new computer (or an additional computer), you know what
needs to be installed on that computer.
Download. After making a backup, go to the www.python.org web site and look for
the Download area. In here, you're looking for the pre-built Windows
installer. This book will emphasize Python 2.5. In that case, the kit is
you click on the filename, your browser should start downloading the
file. Save it in your
Backup. Now is a good time to make a second backup. Seriously. This backup
will have your untouched Windows system, plus the Python installation
kit. It is still cheap insurance.
If you have anti-virus software [
you do, don't
] you may need to disable this until you are done
At this point, you have everything you need to install Python:
- A backup
- The Python installer
You'll need two things to install Python. If you don't have both,
see the previous section on pre-installation.
- A backup
- The Python installer
Double-click the Python installer
The first step is to select a destination directory. The default
destination should be
C:\Python25. Note that Python
does not expect to live in the
C:\My Programs folder.
My Programs folder has a space in the
middle of the name — something that is atypical for all operating systems
other than Windows — subtle problems can arise. Consequently, Python folks
prefer to put Python into
C:\Python25 on Windows
machines. Click to continue.
The next step is to confirm that you want to backup replaced files.
The option to make backups is already selected and the folder is usually
C:\Python25\BACKUP. This is the way it should be.
Click to continue.
The next step is the list of components to install. You have a list
of five components.
- Python interpreter and libraries. You want this.
- Tcl/Tk (Tkinter, IDLE, pydoc). You want this, so that you
can use IDLE to build programs.
- Python HTML Help file. This is some reference material that
you'll probably want to have.
- Python utility scripts (Tools/). We won't be making any use
of this; you don't need to install it. It won't hurt anything if you
- Python test suite (Lib/test/). We won't make any use of
this, either. It won't hurt anything if you install it.
There is an
is necessary if you are using a company-supplied computer for which you
are not the administrator. If you are not the administrator, and you have
permission to install additional software, you can click on this button to
get the Advanced Options panel. There's a button labeled
that you'll need to click in
order to install Python on a PC where you don't have administrator
You can pick a Start Menu Group for the Python program, IDLE and the
help files. Usually, it is placed in a menu named
2.5. I can't see any reason for changing this, since it only
seems to make things harder to find. Click to
The installer puts files in the selected places. This takes less
than a minute.
Click Python on your computer.
; you have just installed
The only problem you are likely to encounter doing a Windows
installation is a lack of administrative privileges on your computer. In
this case, you will need help from your support department to either do
the installation for you, or give you administrative privileges.
menu, under , you will now have a group that lists five things:
- IDLE (Python GUI)
- Module Docs
- Python (command line)
- Python Manuals
- Uninstall Python
GUI is the Graphic User Interface.
We'll turn to IDLE in the section called “The IDLE Development Environment”.
If you select the
Python (command line) window.
This will contain something like the following.
menu item, you'll see the
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on
Type "help", "copyright", "credits" or "license" for more information.
If you hit
, Python will exit. The basic
Python program works. You can skip to the
next chapter to start using Python.
If you select the
item, this will open a Microsoft Help reader that will show the complete
Python documentation library.