physics resources

physics resourcescoursespython information

PHYS 250: Python Information

In this course Python will be used for all computational work. We will mainly interact with it via the Jupyter notebook. The Jupyter notebook is a powerful computational environment that combines documentation and code in a single file. Here is a bit of information about the environment we will be using and a few tasks you must perform early in the semester.

Jupyter Notebook

A Jupyer notebook is a single document containing the full documentation and executable code for a project. This was formerly called the IPython notebook, you will often see it called this when searching for information online (and perhaps even on this website). The code in a notebook can be in many different languages, in fact, many different languages can be used concurrently in a single notebook. For our purposes we will only use Python. This also means we will be using matplotlib for plotting and numpy and scipy for numerical work.

General Information

The Jupyter notebook has undergone rapid development in the past couple of years and has evolved into an exceptional platform for computational work, both in education and in research. In fact, it is not just useful for Python. The core has been split into a new project, call Jupyter. There is a diverse set of information online, a little of which we will use. Some important sources are listed here:

Webpages is the main source of information.
NBViewer allows for any Jupyter notebook available on the web to be viewed without needing Jupyter installed on your system. It also provides a large collection of notebooks (and full books!) in a variety of programming languages that serve as examples for notebooks.
PyVideo is another collection of videos and tutorials. In particular, the SciPy conferences typically have excellent tutorials (we will be using one of them as discussed below). The material for these tutorials is available as Jupyter notebooks so you can follow along on your own. If you are interested in statistics, astronomy (using astropy), symbolic manipulations (through sympy), etc., there are tutorials for the watching.
GitHub provides a version control system based on git, in the cloud. Unfortunately we will not be using it in the course. However, version control is very important, useful, and should be used. Further, GitHub integrates nicely with many of the tools we are using so is a natural choice. If you are familiar with git and/or have a GitHub account you should feel free to use it.


You are required to watch an introductory video on IPython. This video is part 1 of a 3 part tutorial from the SciPy 2013 conference. It is difficult to find a succinct introduction. There are many videos like this one, including a tutorial from the SciPy 2014 conference, but they almost always wander into details we do not immediately need to know. This one is a bit old but contains enough to get us started without too many diversions. It is presented by the original developer of IPython. As noted above, its name has been changed to Jupyter, the notebook will look a little different, etc., but the basic information is still good.

This video itself is over an hour long and the full tutorial is about 3 and a half hours long. To avoid having to sit through all of that I have broken down this tutorial into approximate time stamps to help you get through it. Since it is a tutorial for people in the audience there will be some dead time. I will try to highlight the important points, that is, what you should get out of the video. As noted above, there are many other videos and you are free to watch more. This is the only one that is required.

Tutorial introduction for local participants. Not necessary to watch.
High level overview of IPython and the environment built around it. It also contains a brief discussion of installing IPython (and all the related tools we need) for yourself. This is useful to watch to get a general introduction.
More local information to get the participants up to speed for the main tutorial. This is safe to skip, though it does discuss how to get the tutorial materials which you can download and use to follow along, if so desired.
Beginning of the tutorial, but it gets off to a slow start. It is worth starting here but do not get too distracted, important stuff will be coming up soon!
The main part of the tutorial. This is a long stretch but the beginning is very important. In particular the discussion of how to use and get help in the IPython notebook is essential (and one of the most useful features of the notebook). Since this is a long section you may get bored and stop paying attention so I will point out that around 1:06 there is a brief discussion of %pylab. This, along with the introductory stuff previously mentioned, will be the subject of the first lab (Lab0).
Wrap up of the tutorial session with some questions answered. This is mostly technical details. It is not necessary to watch.

Python Version

As a technical detail, there are two versions of python, python2 and python3, in use. Though python2 is still supported (and will be for many more years) it is generally best to use python3, particularly if just starting out. We will only be using python3 in this course.

Installing the Software

Depending on your operating system the installation can be easy, as in it is all done for you, or a lot of work collecting all the required pieces. I have fortunately never been forced to use a Mac or Windows and thus am blissfully free of the pain such use entails. Regardless, some guidance can be provided and fellow students should be able to help too. For these systems the recommended distribution is the Anaconda distribution. Make sure you get the distribution containing Python version 3.


It should not be hard to install free software with dependencies such as we are doing here. It should be as easy on all systems as it is on Linux/*BSD (where it just requires one command to be run and the systems in place figure out all the dependencies, download them for you, and install them). The fact that this is not the case is a tremendous failure of the major vendors, Microsoft and Apple. They have no interest, it seems, in letting you use your computer as a general purpose device. Free, powerful tools such as Jupyter and the supporting libraries can and do run on all systems. Unfortunately these vendors do not makes it easy to install useful software. They seem to be content with leaving the system open to malware while making it hard to install software that they do not control.


Linux and BSD systems have had package management for decades. Your system likely already has Python installed and it should be easy for the package management system to install all of the required packages.


Although all the software we need is freely available and it is fun to install the pieces I am not going to provide instructions here. If you are interested I am happy to give you guidance.

Anaconda distribution

This is the recommended distribution to use. It includes everything we need for this course, and a lot more. I will be using this distribution for the development of course materials and demonstrations.

The download page for the Anaconda distribution contains all the information you need for obtaining and installing on your computer. The quick start guide should help you get your environment set up. Note: They do include a version for Linux and I will be using it for this course!

Enthought distribution

This distribution should also work fine, but is no longer the recommended version (it has been in previous semesters). There is nothing wrong with using it though I have not reviewed the versions of the software it includes.

Enthought, a company that does a lot of work on numerical python, has provided its own distribution that should include everything you need. For educational users the full distribution is freely available from their store. You can request an academic subscription, but I have not gone through that process so do not know anything about it.