Python and Jupyter

Downloading Anaconda

Fortunately, there is a convenient all-in one solution for our Python needs: the Anaconda distribution, which comes with all the tools and libraries we will need for scientific computing.

Download the appropriate version for your operating system from here and install it on your system.

Make sure to get the version 3.7 of Python! Python v2.7 is being phased out.

Installing Anaconda

The main installation steps for Anaconda are very similar on the different operating systems.

  1. After starting the installer, a license agreement will pop up on screen. Accept it.
  2. Install for All Users (this assumes you have admin privileges; it avoids later problems if you can do this). Allow the installation if your virus protection software asks you.
  3. It is suggested you accept the suggestion for the installation location (e.g., C:\ProgramData\Anaconda3 on Windows).
  4. (Windows only): Make sure that the select Advanced Options include “Register Anaconda as my default Python 3.7” and click Install.
  5. The installer will give you the option to install Microsoft’s VSCode editor. Jupyter has its own editor “built in”, so it is not necessary to install an additional tool for our purposes. You may want to consider VSCode as an option for other coding efforts.
  6. If everything worked, you will get a message thanking you for installing Anaconda. There will be two already-checked boxes: You do not need to sign up for Anaconda Cloud, so uncheck this, but you may want to read “Getting Started with Anaconda”. Hit Finish to complete the installation.

You do not need an Anaconda Cloud account to download and use the distribution!!

Reference Materials

Here we collect some useful cheat sheets on basic Python and Jupyter usage, as well as the most important libraries we are going to use for computational work.

Python and Jupyter Basics

Python Cheat Sheet: This is a useful compilation of essential Python/Jupyter commands for common computing tasks (checks, loops, etc.).

Python Basics: Another collection of the essential Python language constructs.

Jupyter Notebooks: Essentials of Jupyter notebooks - think Mathematica, but powered by Python.

Debugging Python: Sooner or later you will have to do some debugging. This flowchart will hopefully help you to make sense of the Python error messages, and remind you of rudimentary debugging procedures.

Libraries

Matplotlib: Matplotlib is one of the most popular libraries for plotting in Python. Use it in your Jupyter notebooks.

SciPy: Python’s collection of routines for scientific computing (special functions, linear algebra etc.). Interfaces with NumPy for efficiency.

NumPy: NumPy, and in particular the NumPy data structures, are used for efficient numerical computation in Python. NumPy provides wrappers for many highly optimized numerical libraries, allowing you to exploit features like parallelization from your Python code - today, there are high-performance applications running on supercomputers that are written in Python, using NumPy for their numerical heavy lifting!