Installing Python and Required Packages

Instructions for the 2012/2013 academic year.

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

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.

University of Toronto Physics Python Distribution (UTPPD): 2012 Release


As of August 2012 we are releasing a new version of the UTPPD software. Downloading and installation instructions are provided below.

Do the following:
1. Install and download the software
There are different instructions for Windows and MacOS.

  • For Windows operating systems (we assume that you have administrative privileges on your computer):
    • Click on this link to download the required ".exe" file: http://www.physics.utoronto.ca/~utppd/pub/Windows/utppd-2012.4-win32.exe.
    • Locate the "utppd-2012.4-win32.exe" and right click on it. Select "Run as administrator" from the menu that appears. This will ensure proper installation.
    • You will be asked if you want to install software from an "Unknown publisher". Click yes. Installation requires you to click "Yes", "Finish", "Next", "Close", etc. several times. For the standard installation, accept all standard options offered to you.
    • Now proceed to test the software.
  • For Mac OS operating systems (we assume that you have administrative privileges on your computer):
    • Click on this link to download the required ".dmg" file: http://www.physics.utoronto.ca/~utppd/pub/MacOSX/utppd-2012.1.dmg
    • Open the ".dmg" file and run the file utppd-2012.1.mpkg. To open the file, right click on it and select "Open" and accepting the request to install.
      • This method of opening the file is recommended over double clicking the file. This is because in Mac OS X 10.8 Mountain Lion double clicking on "unsigned" executables will result in an error message saying something like: ""utppd-2012.1.mpkg” can’t be opened because it is from an unidentified developer. Your security preferences allow installation of only apps from the Mac App Store and identified developers."
    • Installation requires you to accept terms. For the standard installation, accept all standard options offered to you.
    • Once installation has completed, proceed to test the software.


2. Test the software
Now 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:
2a. Open Idle
If you are running Windows,:
Start → All Programs → Python 2.7 → IDLE (Python GUI)
The typical result will be a window labelled "Python Shell" which will look like the following (version information will be different):
windows-pythonshell.png:
If you are running MacOS, from the Applications folder, open IDLE as follows:
Applications → Python 2.7 → IDLE will open a "Python Shell" which will look like the following
(version information will be different):

idle-screenshot.jpg
There are other ways of running Python, but these are beyond the scope of our current documentation.

Caution 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 by clicking them with the mouse.

We DO NOT recommend that you open these files by clicking on them. Why? Because quite often the result can be unpredictable. Instead, use the method described below and in the tutorial: start IDLE and open Python scripts inside an IDLE session.

2. Run some example scripts:
2a. Download the example scripts:
Download the example scripts in the file examples.zip that can be downloaded here. Download the file and "unzip" it; you now have a folder called "examples".
2b. Run the bounce script
In the IDLE program, using File → Open in Windows or Mac OS, go to examples folder you have just downloaded 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. The contents of a script is called a "module" in Python terminology. In the menu, select Run → Run Module. (A shortcut for this is to press the function key F5.) 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.

2c. 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 with First Steps, Part 1.

 

Yes.