Installing Python and Required Packages


New Instructions for 2017

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 available in our software repository.

System Requirements:
  • Intel 64-bit based computer (most new computers you buy will satisfy this).
  • Windows 7 or later or Mac OS X 10.10 (Yosemite) or 10.11 (El Capitan).

Background Note

The Physics Python distribution is based on the Anaconda Python distribution produced by Continuum Analytics. For 2016, UTPPD will be based on Python 2.7. Migration to Python 3 is planned in the near future. The main reason we continue to use Python 2.7 is for compatibility with the VPython package for 3D programming.

Windows Installation

Execute the following instructions from the account you will use for your work.
  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 UTPPD setup and configuration scripts: setup.bat and utppdconfig.ps1.
  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. (Note: Installation may take 20 minutes. Just let it finish.)
  5. Open the folder in which you downloaded the installation files and double-click on the setup.bat file. (It may only appears as setup, depending on your local settings.)
With the installation completed, you can now move on to testing, as described in Software Testing.

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 to your Downloads folder 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-click on the UTPPD2016 icon, which 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. (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 Software Testing.

Note: If you want or need to run python from the MacOS Terminal, see the optional section at the end of this document.

Software Testing

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

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 VIDLE and open Python scripts inside a VIDLE session.

Open VIDLE

  • If you are running Windows:
    Start → All Programs → Anaconda2 (64-bit) → VIDLE (Python GUI)
  • If you are running OS X:
    Applications → UTPPD2016 → <right click or control click the first time> VIDLE
    You need to right click or control click the first time you open VIDLE in order to approve use of this application from a third-party (non-Apple) site.

On both Windows and Mac OS X, the typical result will be simple blank text document. Fonts might appear small for you; you can adjust font size and other settings using Options → Configure IDLE ...

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

Optional: Running Python at the Command Line

Windows

Windows users are particularly fortunate because the Python distribution comes with a special version of the Windows command-line application, cmd, called Anaconda Prompt, which ensures that you can run the correct Python interpreter by simply typing python. Look for Anaconda Prompt under the Anaconda2 (64-bit) folder in the applications menu.

MacOS / OSX

To run our python from the command-line under MacOS is a little more complicated. MacOS supplies a command-line interface named Terminal (Terminal.app on the filesystem) which can be found in /Applications/Utilities. By default, the terminal application runs an interactive program -- the one that accepts your typed input and provides results -- called the bash shell. When you ask bash to run python, it searches through a list of directories that will NOT include the UTPPD python by default. At the same place where you obtained the UTPPD installer, you can find a small bash shell script called utppd. Append the contents of that script to the end of your bash configuration file, ${HOME}/.bashrc and then, in the same Terminal shell, type:

exec bash

At this point you should be able to simply type utppd in order to set up your environment correctly to run the UTPPD python and find it modules.

Additional Notes for PHY 407 Students

Please see Extra Packages for PHY407.


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