Getting Started with Python 3: Computational Physics at U of T

1. Introduction

Starting Fall 2017, Computational Physics at U of T:
  • Will be switching to Python 3 (instead of Python 2)!
  • Will be switching to the Anaconda distribution of Python 3 (instead of our previous UTPPD)!
  • Will mainly document using Anaconda Python 3 with Spyder (instead of VIDLE)!
  • Mainly because of the switch to Python 3, will no longer be supporting VPython (imported through the visual module) in our materials, at least for this year!

If you're interested in background on the Python 3 migration and the other changes, read this background information.

Migrating from Python 2 to Python 3 is ongoing and we apologize for any out of date documentation. Please see the background information for a couple of tips on how to convert from Python 2 to Python 3. We will try to let you know if any links point to non-updated documentation.

"I need help!!": If you are a University of Toronto Physics student and need help, feel free to email questions to In your support requests, please include
  • Your name.
  • Your student number.
  • The course (or research project) you're in.
  • A detailed description of your problem, including the computer you are using, the OS version, and the issue itself.

We will not be able to help you unless you provide this information. We cannot provide help to folks outside U of T Physics.

2. Installing Anaconda Python 3

So, let's get started on installing Python 3 on your computer!
To install this software:
  • Read the instructions on installing to the end.
  • Then try to download, install, and set up Python 3 on your computer.
  • Finally, test out your distribution and get familiar with software by working through "3. Getting started with Anaconda Python 3/Spyder".

Here are the instructions on installing:
  1. Go to and follow the "Download Anaconda" link, which takes you to
  2. Click on the tab for your platform of choice for your computer (Windows/Mac/Linux).
    • You will typically choose 64-bit for newer computers.
    • If you are a current U of T Physics student who is unsure how to follow the provided instructions, please feel free to contact for assistance.
    • If you have an older computer or OS version, and find that the distribution you download in this way does not work, you can go to the archive of previous distributions, linked from the anaconda downloads page, and find a distribution that more closely matches your computer platform.
  3. Install the software following the prompts.
    • We recommend default installation. This is installation for you as a sole user, not system wide.
    • If you have installed a previous version of anaconda (e.g. a Python 2 distribution) and wish to maintain multiple versions, we will assume that you know how to deal with this but can't offer support for this at this time.
    • Otherwise, we recommend you uninstall the previous version of anaconda. See for uninstall instructions.

3. Getting started with Anaconda Python 3/Spyder and running scripts

By this point, you should have installed Anaconda Python 3.

Below are a few steps to test your distribution and get familiar with how to run your new Python 3 software.

(Note: to avoid unexpected behaviour, open .py files from your Python IDE instead of clicking on them. It is usually better for you to open Python scripts (.py files) from inside your IDE session than by clicking on the file itself. This is because your computer may be set up to run another version of Python when you open a .py file, or because your computer may not know what to do with .py files at all.)

Spyder, which is included in the Anaconda Python distribution, is the Integrated Development Environment (IDE) that we will document in these help pages (see 1. Introduction).

To find and execute the command to start Spyder, separate instructions for Windows (Section 3a) and Mac OS (Section 3b) are provided below.

3a. Windows startup instructions

  • On Windows, a link to Spyder can be found in Start Menu → Programs → Anaconda3 (64-bit).
    • The simplest way to find it is to search for Spyder and click on the icon for the Spyder application.
    • You can then install a shortcut to your favourite location.
    • When you start Spyder for the first time, it will sometimes take a long time (a couple of minutes) for the initial splash screen to appear.
      • If it doesn't appear after a few minutes, try starting it again, and if it still doesn't appear and you are a current U of T Physics student, contact for help.
    • Once you've started Spyder the first time, you might need to click past a couple of dialogue boxes.
  • Once you've started Spyder, you should see a screen that looks like the following:Screen Shot 2017-07-24 at 5.37.44 PM.png
  • We'll go into the details of the different parts of the Spyder in our tutorials.

3b. Mac OS X startup instructions

  • On Mac OS, Spyder can be found at anaconda → bin → spyder in your home folder.
  • You can also search for Spyder in Spotlight
  • Opening Spyder will first open a terminal session and then open a graphical Spyder window.
    • You might see a message suggesting that there is an "Update Available". You can ignore this.
    • Also, a terminal session will be started with a bunch of messages of the form:
      [warn] kq_init: detected broken kqueue; not using.: Undefined error: 0
      • These can be safely ignored
  • The result will look something like what is shown below.
    Spyder Mac OS.png
  • We'll go into the details of the different parts of the Spyder window in our tutorials.

4. Testing your software

We will explore more how to use the Spyder Integrated Development Environment (IDE) in our tutorials. For now, to test if your distribution is working, do the following:
  • Download the histogram demo script, which is taken from the matplotlib gallery.
  • Open it from inside Spyder and run it by pressing the play button or F5.
  • The result should be a window inside the Spyder session that looks like the following:
    Screen Shot 2017-03-31 at 6.25.59 PM.png
  • Download and run the error bar script.
  • See if you obtain the following inside the Spyder session:
    Screen Shot 2017-03-31 at 6.28.59 PM.png

5. Recap

  • You should have now installed Anaconda Python on your computer.
  • You should have also found the Spyder IDE and started a session with it.
  • You had a chance to download and test a couple of Python plotting scripts inside Spyder.
  • If you were interested, you learned some background on the software used at

Well done! Now you are ready to work through our four part tutorial, starting with Part 1.

The site content is Copyright Department of Physics, University of Toronto.