Materials¶
Learning Objectives¶
By the end of this lecture, students will be able to:
Create and configure a GitHub account
Install and configure VS Code with Python extensions
Install the
uvpackage manager on their operating systemInitialize a Python project with
uvAdd scientific computing packages to their project
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:
Submit assignments
Track changes to your code
Collaborate on projects
Build a portfolio of your work
Creating an Account¶
Navigate to github.com
Click “Sign up”
Use your JHU email address for educational benefits
Choose a professional username (this will be visible to future employers)
Complete email verification
GitHub Student Developer Pack¶
Installing GitHub Desktop¶
GitHub Desktop provides a graphical interface for Git, making version control more accessible.
Download from desktop.github.com
Install and sign in with your GitHub account
Grant permissions when prompted
GitHub Desktop handles authentication automatically, so you won’t need to configure SSH keys or tokens.
Configuring Git (Optional)¶
Note
For command-line users: If you prefer using Git from the terminal, configure your identity:
git config --global user.name "Your Name"
git config --global user.email "your-email@jhu.edu"This step is optional if you’re using GitHub Desktop exclusively.
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¶
Download from code
.visualstudio .com Run the installer for your operating system
Launch VS Code after installation
Recommended Extensions¶
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 | shHint
Homebrew alternative: If you use Homebrew, you can install with brew install uv instead.
Linux Installation¶
curl -LsSf https://astral.sh/uv/install.sh | shVerifying Installation¶
Confirm uv is installed correctly:
uv --versionPart 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 ~/githubWindows (PowerShell):
mkdir ~\github
cd ~\githubInitialize a New Project¶
Create your course repository folder and initialize it:
mkdir moma
cd moma
uv initYour full path will be ~/github/moma, which will later sync with your GitHub repository online.
This creates:
pyproject.toml— project configuration and dependencies.python-version— specifies the Python versionmain.py— a sample Python fileREADME.md— project documentation.gitignore— files to exclude from version control
Project Structure¶
~/github/
└── moma/
├── .gitignore
├── .python-version
├── README.md
├── main.py
└── pyproject.tomlPart 5: Adding Dependencies¶
Course Packages¶
Add the packages we will use throughout the course:
uv add numpy scipy matplotlib mystmd jupyterThis installs:
numpy— numerical arrays and linear algebrascipy— optimization, integration, and scientific routinesmatplotlib— plotting and visualizationmystmd— MyST Markdown for writing and publishing documentsjupyter— interactive notebooks (includes JupyterLab, Notebook, and related tools)
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 --versionPart 6: Running Python Code¶
Using uv run¶
Execute Python scripts within the project environment:
uv run python main.pyInteractive Python¶
Start an interactive session:
uv run pythonJupyterLab¶
Launch JupyterLab for interactive notebook computing:
uv run jupyter labThis 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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17import 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