VS Code Setup
- ▸Install VS Code and the Python extension
- ▸Select the .venv interpreter for each session folder
- ▸Run scripts from the integrated terminal and the Run button
- ▸Use breakpoints and the Python debugger
VS Code is the recommended editor for this course. It gives you syntax highlighting, a one-click run button, a built-in terminal, and a proper Python debugger — everything you need to move fast during the hands-on sessions.
Step 1 — Install VS Code
- Download from https://code.visualstudio.com/download
- Run the installer (accept the defaults).
- On Windows, check "Add to PATH" and "Register Code as editor for supported file types" during install.
- Open VS Code once to finish initial setup.
Step 2 — Install the Python extension
The official Python extension from Microsoft gives you interpreter selection, linting, debugging, and the Run button on each file.
- Click the Extensions icon in the left sidebar (or press Ctrl+Shift+X / Cmd+Shift+X).
- Search for "Python" — the publisher should be "Microsoft".
- Click Install.
- Also recommended: "Pylance" (auto-installed with Python) and "Python Debugger".
Step 3 — Open the course folder
Open the session folder you want to work in — not the parent AICourse folder. Each session has its own .venv and .env, and VS Code's Python extension picks them up per folder.
- File → Open Folder (or Cmd+O / Ctrl+K Ctrl+O).
- Select a session folder, e.g. AICourse/Session1.
- If prompted "Do you trust the authors of the files?" — click Yes.
Step 4 — Select the Python interpreter (.venv)
This is the single most important step. VS Code needs to know which Python to use. Point it at the .venv you created in the Overview page so it gets all the installed packages.
- Open any .py file in the folder (e.g. src/01_text_basic.py).
- Press Ctrl+Shift+P (Cmd+Shift+P on macOS) to open the Command Palette.
- Type "Python: Select Interpreter" and press Enter.
- Choose the one labelled ('.venv': venv) — it should have a star or "Recommended" next to it.
Step 5 — Open the integrated terminal
You will run the exercise scripts from the terminal inside VS Code, not a separate window. VS Code will auto-activate your .venv in new terminals once you have selected the interpreter.
- Open the terminal with Ctrl+` (backtick) or View → Terminal.
- Check the prompt starts with (.venv). If not, activate it manually: source .venv/bin/activate (macOS/Linux) or .\.venv\Scripts\Activate.ps1 (Windows).
- Verify: which python (macOS/Linux) or where python (Windows) — it should point inside .venv.
Step 6 — Run a script (two ways)
Option A — Run button
Open any .py file and click the ▶ triangle at the top-right of the editor. VS Code runs it in the terminal using your selected interpreter. Fastest for scripts that need no arguments.
Option B — Terminal command (recommended for CLI scripts)
Many exercises take command-line arguments like --prompt. For those, run them from the integrated terminal:
Step 7 — Load environment variables from .env
Every script calls load_dotenv() internally, so .env is picked up automatically when you run from the terminal. But when you use the Run button or the debugger, VS Code can also read it if you point it at .env in the Python extension settings.
{
"python.envFile": "${workspaceFolder}/.env",
"python.terminal.activateEnvironment": true
}Step 8 — Use the debugger (optional but powerful)
- Click the left margin next to a line number to set a breakpoint (red dot).
- Press F5 to start debugging.
- When prompted "Debug Configuration", pick "Python File".
- Execution pauses at your breakpoint — inspect variables in the left panel.
- Step through with F10 (over) and F11 (into).
Recommended extensions (nice-to-have)
- Python (Microsoft) — required
- Pylance — faster IntelliSense
- Ruff — fast linter for Python
- GitLens — supercharged git integration
- Error Lens — inline error messages
- DotENV — syntax highlighting for .env files