Setting Up Python

In this course we’ll write Python in Jupyter notebooks. All notes are available as notebooks you can download and run locally. There are a few ways to get a working Python environment. If you’re not sure which to pick, go with Google Colab or Anaconda. The other options are there if you already know what you’re doing.

Google Colab

The quickest option, especially if you don’t want to install anything. Google Colab runs Python in the browser and all you need is a Google account. Click New notebook after logging in and you’re ready to go.

The main downside: libraries that aren’t pre-installed need to be reinstalled each session with !pip install.

Anaconda

A full Python distribution that bundles Jupyter and most scientific libraries out of the box. Installers for Windows, macOS, and Linux are at https://www.anaconda.com/download. After installation, launch Jupyter through the Anaconda Navigator.

This is the most straightforward local setup for most users.

Using an IDE

If you’re running Python locally (Anaconda, pyenv, or a direct install), you’ll want a code editor beyond the basic Jupyter interface. Visual Studio Code is the most widely used option — it has a Jupyter extension that lets you run notebooks directly inside the editor, with better navigation, debugging, and Git integration than the browser-based Jupyter UI. Anaconda Navigator can also launch VS Code with the right environment already configured.

Other options include JupyterLab (a more capable successor to the classic Jupyter notebook interface) and PyCharm, which has strong Python support but is heavier. For most purposes in this course, VS Code or JupyterLab is enough.

Coding Agents

One tool worth adopting early is a coding assistant. GitHub Copilot (available in VS Code) and Cursor are the most widely used — they suggest code as you type and can explain errors, generate boilerplate, and help you understand unfamiliar functions. For a course like this, where you’ll frequently encounter new libraries and methods, a coding assistant can cut a lot of time spent looking things up.

This doesn’t replace understanding what the code does. But it does change how you get there — less time on syntax, more time on thinking about the analysis itself.

Python Directly

You can install Python from https://www.python.org/downloads/ and then install Jupyter separately with:

pip install jupyter

This keeps things minimal but requires more manual setup.

Pyenv (macOS / Linux)

Pyenv lets you manage multiple Python versions on the same machine. Useful if you work on other projects with different Python requirements.

macOS

Install via Homebrew:

brew update
brew install pyenv

Then add pyenv to your shell (~/.zshrc on modern macOS):

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

Linux

Install using the official installer:

curl https://pyenv.run | bash

Then configure your shell (~/.bashrc for Bash):

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

Once installed, list available versions and install the latest stable Python:

pyenv install --list
pyenv install 3.x.x  # replace with the latest 3.x.x from the list above

Windows

The main pyenv project doesn’t support Windows natively, but there is a separate pyenv-win project that works the same way. Alternatively, you can use Windows Subsystem for Linux (WSL 2) and follow the Linux instructions above.

Installing Course Libraries

Regardless of your setup, you’ll need a handful of libraries throughout the course. If you’re using Anaconda, most of these come pre-installed. If you’re using a bare Python install or Colab, you can install them with:

pip install pandas numpy scipy statsmodels matplotlib seaborn arch yfinance

In Colab, prefix any pip install command with !:

!pip install arch yfinance

Conda Environments

If you’re using Anaconda and plan to use Python for other projects as well, it’s worth creating a separate environment for this course to avoid library conflicts:

conda create -n finance python=3.13
conda activate finance

Once activated, install libraries with conda install or pip install as above. You can switch back to your base environment at any time with conda deactivate.

Verifying Your Setup

Once you have an environment running, open a notebook and run the following to confirm everything is working:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

print("All good.")

If that runs without errors, you’re ready to go.