Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Development Environment Setup

Modeling Macroeconomics | Lecture 01

Johns Hopkins University

Materials

Learning Objectives

By the end of this lecture, students will be able to:

  1. Create and configure a GitHub account

  2. Install and configure VS Code with Python extensions

  3. Install the uv package manager on their operating system

  4. Initialize a Python project with uv

  5. Add scientific computing packages to their project

  6. Run Python scripts and Jupyter notebooks

Prerequisites

Part 1: GitHub Account Setup

Why GitHub?

GitHub provides version control and collaboration tools essential for modern computational work. We will use it to:

Creating an Account

  1. Navigate to github.com

  2. Click “Sign up”

  3. Use your JHU email address for educational benefits

  4. Choose a professional username (this will be visible to future employers)

  5. Complete email verification

GitHub Student Developer Pack

Installing GitHub Desktop

GitHub Desktop provides a graphical interface for Git, making version control more accessible.

  1. Download from desktop.github.com

  2. Install and sign in with your GitHub account

  3. Grant permissions when prompted

GitHub Desktop handles authentication automatically, so you won’t need to configure SSH keys or tokens.

Configuring Git (Optional)

Part 2: Installing VS Code

Visual Studio Code is a free, powerful code editor with excellent support for Python, Jupyter notebooks, and MyST Markdown.

Download and Install

  1. Download from code.visualstudio.com

  2. Run the installer for your operating system

  3. Launch VS Code after installation

Install these extensions from the Extensions sidebar (Ctrl+Shift+X / Cmd+Shift+X):

Required Extensions

Extension

Purpose

Python

Python language support, debugging, and IntelliSense

Jupyter

Run and edit Jupyter notebooks inside VS Code

MyST-Markdown

Syntax highlighting for MyST documents

To install an extension, search for its name and click Install.

Part 3: Installing uv

uv is a fast Python package and project manager written in Rust. It replaces pip, virtualenv, and pyenv with a single tool.

Windows Installation

Open PowerShell and run:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

macOS Installation

Open Terminal and run:

curl -LsSf https://astral.sh/uv/install.sh | sh

Linux Installation

curl -LsSf https://astral.sh/uv/install.sh | sh

Verifying Installation

Confirm uv is installed correctly:

uv --version

Part 4: Creating Your First Project

Directory Structure

We will use a consistent directory structure throughout the course. Create a github folder in your home directory to store all your repositories:

macOS/Linux:

mkdir -p ~/github
cd ~/github

Windows (PowerShell):

mkdir ~\github
cd ~\github

Initialize a New Project

Create your course repository folder and initialize it:

mkdir moma
cd moma
uv init

Your full path will be ~/github/moma, which will later sync with your GitHub repository online.

This creates:

Project Structure

~/github/
└── moma/
    ├── .gitignore
    ├── .python-version
    ├── README.md
    ├── main.py
    └── pyproject.toml

Part 5: Adding Dependencies

Course Packages

Add the packages we will use throughout the course:

uv add numpy scipy matplotlib mystmd jupyter

This installs:

Verify Installation

Test that packages are available:

uv run python -c "import numpy; import scipy; import matplotlib; print('Success!')"

Verify MyST is installed:

uv run myst --version

Part 6: Running Python Code

Using uv run

Execute Python scripts within the project environment:

uv run python main.py

Interactive Python

Start an interactive session:

uv run python

JupyterLab

Launch JupyterLab for interactive notebook computing:

uv run jupyter lab

This opens a browser window with the JupyterLab interface. You can also open notebooks directly in VS Code using the Jupyter extension.

Quick Test

In VS Code, create a new file test_setup.py in your moma folder:

test_setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import numpy as np
import scipy.optimize as opt
import matplotlib.pyplot as plt

# Simple optimization example
f = lambda x: (x - 2)**2
result = opt.minimize_scalar(f)
print(f"Minimum at x = {result.x:.4f}")

# Plot
x = np.linspace(0, 4, 100)
plt.plot(x, f(x))
plt.xlabel("x")
plt.ylabel("f(x)")
plt.title("Quadratic Function")
plt.savefig("test_plot.png")
print("Plot saved to test_plot.png")

Run it:

uv run python test_setup.py

Summary

Homework