|
|
||
Chapter 2. Python InstallationDownloading, Installing and Upgrading PythonTable 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, 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. 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.
The goal of installation is to get the Python interpreter and
associated libraries. Windows users will get a program called
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. Windows InstallationIn 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. Windows Pre-InstallationBackup. Before installing software, back up your computer. I strongly recommend that you get a tool like Norton's GhostTM. 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
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
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:
Windows InstallationYou'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
( The first step is to select a destination directory. The default
destination should be 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
The next step is the list of components to install. You have a list of five components.
There is an Advanced Options... 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 Non-Admin install that you'll need to click in order to install Python on a PC where you don't have administrator privileges. Click Next 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 The installer puts files in the selected places. This takes less than a minute. Click Finish; you have just installed Python on your computer. Debugging Windows InstallationThe 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. Windows Post-InstallationIn your Start... menu, under All Programs, you will now have a Python 2.5 group that lists five things:
GUI is the Graphic User Interface. We'll turn to IDLE in the section called "The IDLE Development Environment". TestingIf you select the Python (command line)
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 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 Python Manuals menu item, this will open a Microsoft Help reader that will show the complete Python documentation library. |
||