Table of Contents
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 installiung Leopard is undesirable, for some reason, you'll need to do an install or upgrade of Python in your existing Mac OS. We'll cover this 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.
Start with GNU/Linux and UNIX Overview. This section has a quick procedure for examining your current configuration to see if you have Python in the first place. If you have Python, and it's version 2.5, you're all done. Otherwise, you'll have to determine what tools you have for doing an installation or upgrade.
If you have Yellowdog Updater Modified (YUM) see YUM Installation.
If you have one of the GNU/Linux variants that uses the Red Hat Package Manager (RPM), see RPM Installation.
The alternative to use the source installation procedure in "Build from Scratch" Installation.
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 python.
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 Wiki.
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.
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 cheap insurance.
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
python-2.5.. When
you click on the filename, your browser should start downloading the
file. Save it in your x.msidownloads folder.
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?] you may need to disable this until you are done installing Python.
At this point, you have everything you need to install Python:
You'll need two things to install Python. If you don't have both, see the previous section on pre-installation.
Double-click the Python installer
(python-2.5.).x.msi
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.
Because the 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.
There is an button that 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 privileges.
Click to continue.
You can pick a Start Menu Group for the Python program, IDLE and the
help files. Usually, it is placed in a menu named Python
2.5. I can't see any reason for changing this, since it only
seems to make things harder to find. Click to
continue.
The installer puts files in the selected places. This takes less than a minute.
Click ; you have just installed Python on your computer.
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.
In your menu, under , you will now have a group that lists five things:
GUI is the Graphic User Interface. We'll turn to IDLE in the section called “The IDLE Development Environment”.
If you select the
menu item, you'll see the Python (command line) window.
This will contain something like the following.
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>
If you hit Ctrl-Z and then Enter, Python will exit. The basic Python program works. You can skip to the next chapter to start using Python.
If you select the menu item, this will open a Microsoft Help reader that will show the complete Python documentation library.