Install guide: Python, a virtual environment, and pip
Needed from M3 onward. This is your first local install: until now everything ran in the browser (Colab). Take it slowly: setup is the single most common place beginners get stuck, so we go one tiny step at a time, for Windows, macOS, and Linux separately. Nothing here can harm your computer.
What you're installing and why:
- Python: the language itself, so you can run programs on your machine (not just in a browser).
- A virtual environment (venv): a private box for this project's libraries, so different
projects don't tread on each other. (Why it matters: without it, every pip install goes into
one shared pile and versions clash. One venv per project keeps things clean, this is standard
professional practice.)
- pip: Python's tool for installing libraries (other people's code you can reuse). It comes
with Python.
Official docs (verify they open): Python downloads, https://www.python.org/downloads/ ·
venv, https://docs.python.org/3/library/venv.html · pip, https://pip.pypa.io/.
Step 1: Install Python (3.10 or newer)
Windows
- Go to https://www.python.org/downloads/ and click Download Python 3.x.
- Run the installer. On the first screen, tick "Add python.exe to PATH" (this is the step
everyone forgets, it lets you type
pythonin any terminal). Then click Install Now. - Open a new PowerShell window (Start → type PowerShell → Enter).
Check it worked:
python --version
Python 3.12.x (any 3.10+). If you instead see the Microsoft Store open, or
python is not recognized, see Troubleshooting below.
macOS
The Python that ships with macOS is old. Install a current one, easiest is the official installer:
1. Go to https://www.python.org/downloads/ → Download Python 3.x → run the .pkg installer.
2. (Alternative, if you use Homebrew: brew install python .)
3. Open a new Terminal (⌘ + Space → Terminal).
Check it worked:
python3 --version
Python 3.12.x (any 3.10+). On macOS use python3 (and pip3), not python.
Linux (Debian/Ubuntu)
Python is usually present; install the venv/pip extras to be safe:
sudo apt update && sudo apt install -y python3 python3-venv python3-pip
python3 --version
Python 3.10.x or newer. (Other distros: use your package manager, dnf, pacman, etc.)
Which command,
pythonorpython3? On Windows it's usuallypython. On macOS/Linux it's usuallypython3(andpip3). Use whichever your "check it worked" step above accepted, and keep using that one throughout.
Step 2: Make a project folder
Pick the command for your terminal. (New to the terminal? See terminal.md.)
macOS / Linux:
mkdir ai-course && cd ai-course
mkdir ai-course; cd ai-course
ai-course. You're "inside" the project folder.
Step 3: Create a virtual environment
Run this inside your project folder:
macOS / Linux:
python3 -m venv .venv
python -m venv .venv
.venv appears in the project. That
folder is your private library box. (You only create it once per project.)
Step 4: Activate the virtual environment
Activating tells your terminal "use this project's box."
macOS / Linux:
source .venv/bin/activate
.\.venv\Scripts\Activate.ps1
(.venv). That prefix means it's active. (You
re-activate every time you open a new terminal for this project. To leave it, type deactivate.)
Windows error about "running scripts is disabled"? Run this once, then try activating again:
(AnswerSet-ExecutionPolicy -Scope CurrentUser RemoteSignedY. This allows local scripts; it's safe for development.)
Step 5: Install a library with pip
With the venv active (you see (.venv)), install the rich library:
pip install rich
Successfully installed rich-15.x markdown-it-py-…
pygments-…. (pip installs rich plus the small things it depends on.)
Or install everything a project lists at once (when a requirements.txt exists):
pip install -r requirements.txt
Step 6: Check it worked
pip list
rich (e.g. rich 15.0.0). If
rich is in the list, your install works and you're ready to code.
Troubleshooting
| Symptom | Fix |
|---|---|
Windows: python opens the Microsoft Store, or "not recognized" |
You missed "Add python.exe to PATH". Re-run the installer → Modify → tick PATH, or reinstall and tick it on the first screen. Open a new terminal afterwards. |
macOS: python says "command not found" |
Use python3 and pip3 instead. |
pip not found but Python works |
Use python -m pip ... (Windows) or python3 -m pip ... (macOS/Linux), same thing, always available. |
| Windows: "running scripts is disabled" when activating | Run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once (answer Y), then activate again. |
| Installed a library but Python "can't find it" | Your venv probably isn't active, check for (.venv) in the prompt; re-run the activate command from Step 4. |
Prompt has no (.venv) after activating |
You may have created .venv in a different folder. cd into the project folder and re-run activate. |
Secrets hygiene (you'll need it at M4). Soon you'll have an API key: a secret password for an AI service. Keep it in a file named
.env, load it from there, and never type it into your code or commit it to Git. This course's.gitignorealready ignores.env, and each module ships a.env.examplewith placeholder values to copy. We set this up properly in M4.