Installing Python and Required Packages


WARNING: New installation instructions are in progress. 2016-08-22 STB.

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

The Department of Physics computers will already have the Python packages that are required for your coursework. However, it is useful to be able to work on your own computer; so we provide packages and instructions to enable you to get started.

The Current Release of the University of Toronto Python Distribution (UTPPD)

The University of Toronto Physics Python Distribution (UTPPD) is UTPPD2016. There may be minor revisions to add features or fix bugs, in which case you should download the package with the highest version number (e.g. 2016-2 is more up-to-date than 2016-1).
It is impossible to support all possible combinations of hardware and operating systems; so to receive full support, you must be running an Intel 64-bit based computer. This includes all modern (circa 2009 or later) Windows or Mac desktops or laptops, with the exception of some lower end Microsoft Surface hybrid tablet/laptops.
Supported operating systems include:
  • Windows 7, 8, 8.1, 10
  • OS X 10.10 (Yosemite) and 10.11 (El Capitan)
  • OS X 10.12, which is not yet released, will be supported as quickly as possible.
Releases of OS X from 10.6 (Snow Leopard) to 10.9 (Mavericks) are expected to work, but are untested. Releases 10.8 (Mountain Lion) and earlier are no longer supported by Apple.
The UTTPD software for Windows and OS X can be found in our software repository.

Background Notes

The Physics Python distribution has been drastically changed from previous years. It is now based on the Anaconda Python distribution produced by Continuum Analytics. There are two Anaconda Python versions for each operating system: one for Python 2.7 and the other for the latest Python 3.5. UTPPD is based on Python 2.7, rather than the newer Python 3.5, due to local requirements for a package that is not available for Python 3.5.

Windows Installation

We assume that you have administrative privileges on your computer, but you need not be running with administrative privileges.
  1. Visit the UTPPD for 64-bit Windows download area.
  2. Download the installer file: Anaconda2-4.0.0-Windows-x86_64.msi .
  3. Download the VPython installation script: install-vpython.bat .
  4. Double-click on the Anaconda installer file and provide your administrator password if prompted. When completed, you will have a full Python 2.7 distribution useful for Computational Physics.
  5. Now you can go to the Start Menu (or its modern equivalent) and start the Anaconda shell. At the command line, run the install-vpython.bat script.
With the installation completed, you can now move on to testing, as described in the relevant section below.

TODO: Check whether the install-python script needs to be created as a Bash script instead of a Windows .bat file.

TODO: Get screenshots of the Windows 7, 8, 8.1, 10 desktops to show what will be seen in the Application menu after installation.

OS X Installation

  1. Visit the UTPPD for OSX download area.
  2. Download the latest UTPPD2016-x.dmg file.
  3. If it does not open automatically, go into the Downloads (via the Dock or using Finder) and double click on the installer. This should create an icon on your desktop that looks like the following:
    • installer-virtdisk-icon.png
  4. Double-clicking on the virtual disk icon will open a Finder window that looks like:
    • finder-installer-window.png
  5. Now drag the UTPPD2016 folder onto the Applications folder to begin the install, which may take several minutes because there are 2GB of files to unpack and move into place.
With the installation completed, you can now move on to testing, as described in the relevant section below.

Software Testing

Now test the packages you have 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.

Open IDLE

TODO: Fix paths for new UTPPD.
TODO: Get Images showing the Application Menu Entry.

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 OS X, 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.

Run Some Example Scripts

a. 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".
b. 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.

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

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