Python Environment Setup

Installing Python and the tools to prepare for coding classes

It is strongly suggested to get GitHub’s student developer pack which gives you lots of free stuff (and even access to the AI GitHub Copilot ).

Similarly, it is strongly recommended to install VS Code for easy access to both the repositories, and a coding environment to run jupyter notebooks.

All of the slides in these lectures are available as Juptyer notebooks in a github repository, https://github.com/jlperla/grad_econ_datascience_notebooks

NOTE: Relative to other instructions you may see, these emphasize the newer uv Python installation rather than the increasingly outdated Anaconda. The small changes are worth the effort for speed of installation/setup as well as better support for reproducibiilty.

Quick Start

To install a Python and Jupyter environment:

  1. Setup a GitHub ID and apply for the GitHub’s student developer pack

  2. Install git and then VS Code

    • NOTE: For further instructions when using VS Code, you can access different features through the command palette by <Cmd+Shift+P> or <Ctrl+Shift+P> depending on your OS, and then typing in text. When you are given instructions with a > (e.g., > Git: clone) it indicates you should search for that text.
  3. Install uv, which is strongly recommended instead of conda (although both can coexist)

    • MacOS or Linux: curl -sSfL https://raw.githubusercontent.com/astral-sh/uv/main/install.sh | sh, from any terminal
    • Windows: iwr https://raw.githubusercontent.com/astral-sh/uv/main/install.ps1 -useb | iex, from a Windows PowerShell terminal (i.e., Open the Start menu, type Windows PowerShell, select Windows PowerShell, then select Open.)
  4. In VS Code, clone the notebook version of this website

    1. <Cmd+Shift+P> to enter into the VS Code command palette, then type clone to select > Git: clone
    2. Paste in the repository URL: https://github.com/jlperla/grad_econ_datascience_notebooks and choose to open a new window with the repository
    3. If prompted, you likely want to associate your github ID with VS Code to make git operations easier.
  5. Start a terminal in VS Code (e.g., `<Ctrl+`> or from the menu Terminal/New Terminal)

  6. In the terminal, install the appropriate uv packages and python with

    uv sync
  7. Sometimes optional, but helpful to choose the default python environment for a cloned repository with > Python: Select Interpreter and choose ./.venv/bin/python on macos/linux or .\.venv\Scripts\python.exe on windows (likely the default).

  8. In the new window, open files such as slides/probability.ipynb as Jupyter Notebooks.

    • If necessary, choose the Jupyter kernel as the Python Environments... then choose the ./.venv/bin/python interpreter

The python package dependencies are enumerated in the pyproject.toml and uv.lock files. If these are ever changed when you update the notebooks, you can simply run uv sync to install the latest versions.