Python is part of the MacOS environment. Tiger (MacOS 10.4) includes
Python 2.3.5 and IDLE. Leopard (MacOS 10.5) includes Python 2.5.1.
Generally, you don't need to do much to get started. You'll just need to
locate the various Python files. Look in
/System/Library/Frameworks/Python.Framework/Versions
for the relevant files.
In order to upgrade software in the Macintosh OS, you must know the
administrator, or “owner” password. If you are the person who
installed or initially setup the computer, you had to pick an owner password
during the installation. If someone else did the installation, you'll need
to get the password from them.
The Mac OS installation of Python has three broad steps.
- Pre-installation: make backups and download the installation
kit.
- Installation: install Python.
- Post-installation: check to be sure everything
worked.
We'll go through each of these in detail.
Macintosh Pre-Installation
Before installing software, back up your computer. While you can't
easily burn a DVD of everything on your computer, you can usually burn a
DVD of everything in your Mac OS X Home directory.
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 Mac OS 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. A backup is cheap insurance.
You should also have a folder for saving your downloads. You can
create a folder in hour 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 Mac OS X
installer. This book will emphasize Python 2.5. In that case, the kit is
python-2.5.
x
-macosx
date
.dmg
.
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. It is still
cheap insurance.
At this point, you have everything you need to install Python:
- A backup
- The Python installer
When you double-click the
python-2.5.
x
-macosx
date
.dmg
file, it will create a disk image named Universal MacPython
2.5.
x
. This disk image has your
license, a ReadMe file, and the
MacPython.mpkg
.
When you double-click the MacPython.mpkg
fie,
it will take all the necessary steps to install Python on your computer.
The installer will take you through seven steps. Generally, you'll read
the messages and
Introduction. Read the message and click Continue.
Read Me. This is the contents of the ReadMe file on the installer disk
image. Read the message and click
Continue.
License. You can read the history of Python, and the terms and conditions
for using it. To install Python, you must agree with the license. When
you click Continue, you will get a pop-up window
that asks if you agree. Click Agree to install
Python.
Select Destination. Generally, your primary disk drive, usually named
Macintosh HD
will be highlighted with a green
arrow. Click Continue.
Installation Type. If you've done this before, you'll see that this will be an
upgrade. If this is the first time, you'll be doing an install. Click
the Install or Upgrade
button.
You'll be asked for your password. If, for some reason, you aren't
the administrator for this computer, you won't be able to install
software. Otherwise, provide your password so that you can install
software.
Finish Up. The message is usually "The software was successfully installed".
Click Close to finish.
Macintosh Post-Installation
In your Applications folder, you'll find a MacPython
2.5
folder, which contains a number of applications.
Look in
/System/Library/Frameworks/Python.Framework/Versions
for the relevant files. In the bin
,
Extras
and Resources
directories
you'll find the various applications. The bin/idle
file will launch IDLE for us.
Once you've finished installation, you should check to be sure that
everything is working correctly.
Testing
Now you can go to your Applications
folder,
and double click the IDLE application. This
will open two windows, the Python Shell window is
what we need, but it is buried under a Console
window.
Here's what you'll see in the Python Shell window.
Python 2.5.1 (r251:54863, Oct 5 2007, 21:08:09)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "copyright", "credits" or "license()" for more information.
****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************
IDLE 1.2.1
>>>
The menu bar will have a menu named with
the menu item . Use this to finish
using IDLE for now, and skip to the next chapter.
You may notice a menu. This has the
menu item, which you can access
through the menu or by hitting
F1
. This will launch
Safari to show you the Python documents
available on the Internet.