The Python 3 code used in this course uses the following external libraries:

  • Sympy: for symbolic mathematics.
  • Numpy: for numeric mathematics.
  • Scipy: mainly for the numerical solver of differential equations.
  • Nashpy: for Nash equilibria computation.
  • Axelrod: for Iterated Prisoner Dilemma experiments.

Installing Python and the required libraries

The most straightforward way to install Python and the required library and any operating system (Windows, OSX, linux) is to use a scientific distribution called Anaconda. Go to the following link and download the installer corresponding to your system. Be sure to choose Python 3 and not Python 2.

There are installation instruction online:

To check your install has worked correctly open:

  • the "Command prompt" on Windows.
  • the "terminal" on OSX or linux.

type python and press Enter. This should display a screen that looks something like:

Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.

The version numbers might look different but the word Anaconda should be there.

Once you've done that, type exit() and press Enter to exit the Python prompt.

You now have Python along with Sympy, Numpy, Scipy and a number of other useful libraries.

Installing game theory libraries:

To install Nashpy and Axelrod:

  • the "Command Prompt" on Windows.
  • the "terminal" on OSX or linux.

Now type:

pip install nashpy


pip instal axelrod

After each one of those press Enter. This should download and install the required software.

If you are using a machine for which you do not have administrative rights (for example a University lab computer) instead you should type:

pip install --user nashpy


pip install --user axelrod

Using Jupyter

To use Python I recommend using the Jupyter notebook (a popular tool in scientific computation - and also the tool used to build this course).

There are various ways to run the Jupyter server, one is to type:

jupyter notebook

in the Command Prompt/Terminal.

Note that all chapters are available as jupyter notebooks (.ipynb files). You can download them and modify/execute the code.

Further Python

If you want to learn more Python there are a number of great resources online, you can also take a look at my Computing for Mathematics course which is an introduction to Python for mathematicians: