Getting started: installing Python

RSM338: Applications of Machine Learning in Finance Winter 2027

Author

Kevin Mott

By the end of this guide, you will be able to open the Lecture 1 notebook in VS Code, run its first Python cells and see the course price table. Follow the macOS or Windows instructions where they differ.

1 Install desktop VS Code

A Jupyter notebook combines explanations, Python code and the results of running that code. We open and work in these notebooks in the desktop version of Visual Studio Code. Start at the VS Code download page.

1.1 macOS

  1. Download the macOS .dmg. The Universal version works on both Apple silicon and Intel Macs.
  2. Open the downloaded file, drag Visual Studio Code to Applications, and open it from there. Microsoft’s macOS setup guide

1.2 Windows

  1. On the Windows computer you’ll use for class, click Start, open Settings, and choose System → About. Under Device specifications, find System type. That line gives the processor type, usually after “64-bit operating system.” Microsoft’s instructions for finding System type

  2. On the VS Code download page, open All downloads and find the Windows User Installer row. Match the download to what you saw under System type.

    • x64-based processor → click x64.
    • ARM-based processor or ARM64-based processor → click Arm64.
  3. Open the downloaded .exe file and follow the installer prompts. Then open Visual Studio Code from the Start menu. Microsoft’s Windows setup guide

2 Install uv

uv installs the Python version and packages our notebooks use. The commands in this section install uv itself. In Section 5, you’ll use it to set up the course. You do not need to install Python yourself. uv downloads and installs Python 3.13 if your computer needs it. Astral’s guide to Python installation with uv

2.1 macOS

Open Terminal from Spotlight. Paste the following line and press Return.

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

This downloads and runs Astral’s installer. Official uv installer instructions

2.2 Windows

Open Windows PowerShell from the Start menu. Paste the following line and press Enter.

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

The command runs Astral’s installer in a PowerShell session started for this command. If the installer is blocked, see the WinGet option. Official uv installer instructions

2.3 Check that uv is available

After installation, close your terminal and open a fresh one. If VS Code was open, quit and reopen it so its terminal can find the new command as well. Run the following in Terminal or PowerShell.

uv --version

You should see uv followed by a version number. If the command is still missing, check the final lines of the installer output for instructions to add uv to your PATH, the list of folders your terminal searches for commands. Astral’s installer settings

3 Install the VS Code extensions

Open Extensions in the VS Code sidebar. Search for Python and Jupyter, then install both extensions from the publisher Microsoft. The Python extension lets VS Code recognize Python environments. The Jupyter extension opens .ipynb files and connects their cells to a Python process. Python extension · Jupyter extension

4 Save the course files

Download lecture notebooks using the ipynb buttons on the course website. For this setup, click the button next to Lecture 1 to get 20271_RSM338H1S_Lecture1.ipynb.

Download pyproject.toml, uv.lock, and stock_prices_daily.csv from Quercus.

Create a folder called RSM338 in a location you can find again, such as Documents. Inside it, create Data and Lecture1. Save the CSV in Data, the notebook in Lecture1, and the two environment files directly in RSM338. Keep the original filenames.

RSM338/
├─ Data/
│  └─ stock_prices_daily.csv
├─ Lecture1/
│  └─ 20271_RSM338H1S_Lecture1.ipynb
├─ pyproject.toml
└─ uv.lock

Make sure that both environment files sit next to the Data and Lecture1 folders. If you downloaded a second copy of a file or used a browser that appended an extension, check that its saved name still matches the tree.

5 Create the course Python environment

A virtual environment keeps the Python and packages for this course together. Packages add tools to Python. For example, we use pandas to work with tables. If another course uses an older version of pandas, each course can keep the version it needs. In RSM338, we use the same package versions across the class so you can run the examples with the same tools we use in class.

In VS Code, choose File → Open Folder and open RSM338. The Explorer should show both folders and both environment files. Choose Terminal → New Terminal. Enter the commands below in the terminal. Later, you’ll run Python in the notebook’s code cells.

Check the terminal’s working folder by running pwd on macOS or Get-Location in Windows PowerShell. You should see a path ending in RSM338. If you are one level deeper in Lecture1, use cd .. to go back up to RSM338. VS Code terminal guide

Run the following in that terminal on either operating system.

uv sync --locked

pyproject.toml tells uv which Python version and packages the course needs. uv finds or installs Python 3.13 and creates the environment in a folder called .venv. Then it installs the exact versions recorded in uv.lock, including the package that lets VS Code run Python in a notebook. The --locked option tells uv to use the lock file as supplied. Wait for the command to finish. Astral’s project guide · Locking and syncing

Keep one .venv in RSM338 throughout the semester. Add Lecture2, Lecture3 and later lecture folders alongside Lecture1. They share the same environment and Data folder. When updated environment files are posted on Quercus, save both in RSM338 and rerun uv sync --locked there.

6 Select the notebook kernel

The kernel is the running Python process that executes your notebook cells. Selecting the course’s .venv tells VS Code which Python and packages to use for that process.

  1. Open the Command Palette with Cmd+Shift+P on macOS or Ctrl+Shift+P on Windows. Run Python: Select Interpreter and choose the course environment. If you need to locate it manually, choose Enter interpreter path and find .venv/bin/python on macOS or .venv\Scripts\python.exe on Windows inside RSM338. VS Code Python environments
  2. In Explorer, open the notebook inside Lecture1. At the top right, click Select Kernel. If a kernel is already shown, click its name to check or change it.
  3. Choose the course .venv from Python Environments. If you see recent kernels first, choose Select Another Kernel to reach that list. The notebook kernel is a separate selection from the interpreter for Python scripts. VS Code kernel picker

7 Run the first two code cells

In the notebook’s Open the actual table section, click the run triangle beside the import cell or press Shift+Enter with the cell selected. The three imports should finish without an error. Running cells in VS Code

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

Run the next code cell. It loads the CSV into a pandas table called prices and displays the first five rows.

prices = pd.read_csv('../Data/stock_prices_daily.csv',
                     parse_dates=['date'], index_col='date')
prices.head()

The first row should be dated January 2, 2018, with AAPL about 40.48 and MSFT about 79.47. In the file path, .. goes up one folder from Lecture1 to RSM338, then Data leads to the shared price file. This is a relative path. Its starting point is the kernel’s working folder.

You can use Outline in the Explorer sidebar to jump to a heading, and the arrow beside a heading to fold or unfold its section. In Settings, search for Notebook Sticky Scroll to keep the current heading visible while you read. Save changes with Cmd+S on macOS or Ctrl+S on Windows. As you work, run cells in order so later cells can use the variables created earlier.

8 If a setup step fails

Windows blocks the uv installer. If your computer has WinGet, run this in PowerShell, then open a fresh terminal to check uv --version. WinGet instructions for uv

winget install --id=astral-sh.uv -e

uv sync --locked cannot find the project or reports a lock error. Check that the terminal is in RSM338. If pyproject.toml and uv.lock came from separate downloads or different announcements, download the current pair from Quercus and replace both together.

VS Code offers to install kernel support, or an import fails. Check that the terminal sync finished and select the course .venv again in the notebook. The synced environment already includes ipykernel.

Python cannot find the CSV. Check that the filename is stock_prices_daily.csv and the CSV is in the shared Data folder. To check the kernel’s working folder and which Python it is using, run this in a temporary notebook code cell.

import sys
from pathlib import Path

print(sys.executable)
print(Path.cwd())

The first line should point to the Python inside RSM338/.venv. The second should end in Lecture1. If the second line ends in RSM338, run %cd Lecture1 in a temporary notebook cell, then run the two demonstration cells again. The terminal and the kernel keep their own working folders.

A variable such as pd or prices is missing. Run the earlier cells in order. When you restart the kernel, it clears the variables from the previous run.

Later in the course

When instructed to add the neural-network packages, open the terminal in the same RSM338 folder and run the following. Restart the notebook kernel when it finishes.

uv sync --locked --extra neural