Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

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.

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 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.

Windows Installation

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.

  1. Pre-installation: make backups and download the installation kit.
  2. Installation: install Python.
  3. Post-installation: check to be sure everything worked.

We'll go through each of these in detail.

Windows Pre-Installation

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. x .msi. When you click on the filename, your browser should start downloading the file. Save it in your downloads 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:

  • A backup
  • The Python installer

Windows Installation

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 (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 Next 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 Next 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 install it.
  • 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 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 Python 2.5. I can't see any reason for changing this, since it only seems to make things harder to find. Click Next to continue.

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 Installation

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.

Windows Post-Installation

In your Start... menu, under All Programs, you will now have a Python 2.5 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”.

Testing

If you select the Python (command line) 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 Python Manuals menu item, this will open a Microsoft Help reader that will show the complete Python documentation library.


 
 
  Published under the terms of the Open Publication License Design by Interspire