Installing Python and Required Packages

Contact: If you are a student having trouble installing this software, contact compwiki@physics.utoronto.ca

This page provides updates to the compwiki installation for Mac OS 10.6 (Snow Leopard).
The Department of Physics computers already have the Python packages that are required for your coursework. But it's a good idea to install this software on your laptop or home desktop computer, so you can work outside the Department. We have bundled this software and made it available online. A CD copy of the online material is available on request.

Now do the following:
  • To download the package, follow this link, which downloads Version 0.2 of the University of Toronto Physics Python Distribution (UTPPD), released June 17, 2009. The file you download is UTPPD-v0.2.zip.
  • Windows Vista users: This ".zip" file might not unzip properly under Windows Vista. To make sure that it does, download "WinZip". A 45 day evaluation copy of WinZip is available here. Download and install this copy, and use it to unzip UTPPD-v0.2.zip in the next step.
  • Unzip the file UTPPDv0.2 in a directory of your choice, and follow the instructions below.

The UTPPD distribution includes the following standard packages:
  1. Python 2.5: a standard Python distribution.
  2. IDLE: Software that lets you run Python and edit Python scripts.
  3. Standard Python packages: VPython, numpy, scipy, matplotlib
  4. A directory of examples, most of which come from the VPython distribution.

It includes many other packages, and can be expanded to include even more.

Next, we cover the following:
  1. Instructions for installing on Windows
  2. Instructions for installing on Mac OS 10.5
  3. Instructions for a partial install on Mac OS 10.4
  4. Pointers for installing on Linux
  5. Testing the installation
  6. Description of where we obtained the packages

Warning about previously installed Python packages: If you previously have installed other Python packages on your computer, you need to proceed carefully. Consider uninstalling the previous versions. You might see changes in the way some of your previous Python scripts worked.

1. Installation on Windows Vista/XP

  • Our windows distribution is from pythonxy.com. More information is located below. We have included all the files you need in the package under the UTPPDv0.2 directory.
  • In the UTPPDv0.2 directory, open the Windows folder (directory) and run the program (.exe file) pythonxy-install.
    • The first dialog box is the license agreement. Click "I Agree".
    • The next dialog box is "Choose Components". Here is a picture of the dialog:install_dialog2.png
      • Under "Select the type of install:" choose "Custom" from the drop down menu.
      • Under "Or, select the optional components you wish to install", scroll down under the Python checkbox until you see the checkbox for VPython5.0.3. Click the checkbox for VPython5.0.3.
      • Click "Next"

    • The next dialog boxes, "Choose Install Location" and "Choose Start Menu Folder", will let you choose where to install the software and the Start Menu options. Simply click "Next" if you do not want to change the defaults, and then click "Install".
    • The install takes several minutes. You might see some warning messages, but these are not critical. Just click ok on the warning box.
    • When the Install is finished, click "Next" and "Finish".

  • At this point, you've installed everything you need: Python, IDLE, numpy, scipy, matplotlib, and vpython.
  • Now proceed to "Testing the Installation".

2. Installation on Mac OS 10.5

  • Open the Mac folder in the UTTPDv0.2 directory. The directory contains five files, as seen in the screenshot of the finder window below:mac_finder.png
    [The prefix letters a, b1, b2, etc. are for alphabetical sorting.] The required Python distribution requires four installation steps. We will go into a bit more detail on Step 1; the following steps are similar.
  1. Open the file a Mac Python 2.5.4.dmg. This mounts a disk image "Universal MacPython 2.5.4". On this disk image, open the fileMacPython.mpkg. The Install program should run, and your session will look something like this:macpython_install.png
    To do the standard installation: Click Continue three times, click Agree, click Install, enter your password, click OK, wait a few minutes for the install to take place, click Close. If you wish to change anything, read the options carefully and customize according to your needs. Eject theUniversal MacPython 2.5.4 disk image. You have now installed MacPython 2.5, a standard Python 2.5 distribution, and IDLE.
  2. Next, do one of the following to install VPython and numpy.
    • If you are on an Intel Mac, open b1 VPython Intel Mac.zip which will un-archive the file VPython-Mac-Py2.5-5.03_candidate. Open this file and install the VPython software (it is a similar procedure to the one for MacPython).
    • If you are on a PowerPC Mac, open b2 VPython PowerPC Mac.zip which will un-archive the file VPython-MacPPC-Py2.5-5.03_candidate. Open this file and install the VPython software (it is a similar procedure to the one for MacPython).

  1. Next, open the file c Matplotlib.zip, which will unarchive the file matplotlib-0.98.5.2-py2.5-macosx10.5. Open this file and run the matplotlib installer. (The same procedure applies for Intel Mac or PowerPC Mac). You have now installed matplotlib.
  2. Next, open the file d Scipy.dmg, which mounts a disk image scipy-0.7.0-py2.5-macosx10.5. The file scipy-0.7.0-py2.5-macosx10.5.mpkgcan be found on this disk image. Open this file, run the installer, unmount the disk image. You have now installed scipy.
  • At this point, you've installed everything you need: Python, IDLE, numpy, scipy, vpython, and matplotlib.
  • Now proceed to "Testing the Installation"

3. Installation on Mac OS 10.4

VPython can be installed on MacOS 10.4, but we have not put together a pre-built distribution of matplotlib and scipy that is compatible with MacOS 10.4. If anyone can build such a distribution, that includes VPython, matplotlib, and scipy, please let us know.
  • Open the Mac folder under the UTPPDv0.2 directory.
  • Follow the instructions for installing MacPython and VPython for Mac OS10.5.
  • Matplotlib and Scipy installation have not been tested.

4. Installation on Linux

For Linux, we recommend checking if the relevant software is included in your current OS distribution. If it isn't, there are several ways to proceed. For example, PythonXY (www.pythonxy.com) is available for Ubuntu Linux, and Vpython (www.vpython.org) provides Linux distributions. The Enthought Python Distribution on Red Hat supports most of our required packages, but not VPython. Or you could use standard package installation procedures appropriate for Ubuntu, Red Hat, etc..

5. Testing the Installation

We will briefly test the packages you have just installed. First, we will start the IDLE program, which will let you run Python commands and scripts. Then we will run a couple of test scripts. IDLE is described further in the tutorial.

Now do the following:
  1. Open IDLE:
    If you are running Windows, you will be starting IDLE from the Python XY package. From Start Menu, open IDLE as follows:
    Start → All Programs → Python(x,y) → IDLE
    The typical result will be a window labelled "Python Shell" which will look like the following:windows-pythonshell.png
    If you are running MacOS, you will be starting IDLE from the MacPython package. From the Applications folder, open IDLE as follows:
    Applications → MacPython2.5 → IDLE
    The typical result will be a window labelled "Python Shell" which will look like the following:mac-pythonshell.png
    There are other ways of running Python, but these are beyond the scope of our current documentation.

    Remark about opening .py files: Files that have the extension .py are known as Python scripts. In Windows and Mac OS, these files will appear to be "clickable", i.e. will appear to be files that you can open with a double click. We do not recommend that you open these files in this way, mostly because the resulting behaviour can be unpredictable. Instead, use the method described below and in the tutorial, which involves starting IDLE and opening Python scripts within the IDLE session.
  2. Run the bounce script:
    In the IDLE program, using File → Open in Windows or Mac OS, go to examples folder under the UTPPDv0.2 directory and open the file called "bounce", which might show up as bounce or as bounce.py in the directory listing.

    You will now run the script, known as a "module" in Python terminology. In the menu, select Run → Run Module. (A shortcut for this is to press the function key F5, but there are reports that this does not work consistently on the Mac distribution.) This should produce an animation of a bouncing ball (see below)and verifies installation of VPython.
    visual_snapshot.jpg
    Finally, close the bouncing ball animation.
  3. Run the plot example script:
    In the examples folder, find the file called matplotlib_example.py, which might show up as matplotlib_example or matplotlib_example.py.
    Run this module as you did the bounce module (Run Module or the shortcut F5). You might need to wait a minute or so before anything happens. This should produce a plot of global mean surface temperature, using data from the NASA GISS website (see screenshot below). This verifies installation of the matplotlib module. Close the window and quit IDLE.
    matplotlib_snapshot.jpg

You have now completed a limited test of the Python distribution you installed. Congratulations! You are ready to move on to the Tutorial, starting withFirst Steps, Part 1.

6. Where did our Python packages come from?

We used the following sources for our Python distribution:
  • For Windows, we used as a base Python XY (www.pythonxy.com), following the "Web" installation and choosing the "Full" edition. This installation includes Python 2.5, IDLE, numpy, scipy, and matplotlib, and vpython. It also installs several other packages that are worth exploring, e.g. iPython as an alternative to IDLE.
  • For Mac OS10.5, we used as a base the vpython.org Python distribution. This includes MacPython2.5 and IDLE. On top of this, we installednumpy and visual using the VPython module appropriate to our architecture (PPC vs. Intel). In addition, we installed matplotlib and scipyfrom sourceforge.net.
  • The examples folder includes the standard VPython examples from the VPython distribution. We created the matplotlib_example.py ourselves, which used the NASA GISS global temperatures downloaded from their website.

The compwiki.physics.utoronto.ca site content is Copyright 2009 Department of Physics, University of Toronto.






The compwiki.physics.utoronto.ca site content is Copyright 2009 Department of Physics, University of Toronto.