Running Python on Your Own Computer
Colab is enough for the whole course. This page is for when you want Python on your own machine: to try the interactive prompt in a terminal, to run scripts the way working programmers do, and to build the Booknook repository in a real folder with a virtual environment. It is the one run-locally page for the course; Module 1 Lesson 2 and Module 7 Lesson 4 point here.
None of the steps on this page can run inside a Colab notebook. The macOS steps were run on 14 October 2026 with Python 3.12.15 and the outputs shown come from that run. The Windows and Linux steps were not run; they follow Python's own documentation ("Using Python on Windows" at docs.python.org) and the package pages named below.
1. Which Python to install
Install Python 3.12. It is the version Colab runs, so every output in the course will match yours exactly. Any newer version (3.13, 3.14 and later) also runs all the course code, because the course uses nothing that later versions removed; the main difference you will notice is the interactive prompt (section 4).
One thing to know before you download: 3.12 is now in its "security fixes only" stage. Python's website still lists new 3.12 releases, but for those it publishes only the source code, not a ready-to-run installer. The last 3.12 release with installers for Windows and macOS is 3.12.10, and that is a fine version for this course. The routes below get you a working 3.12 either way.
2. Install it
Windows
The Python team's recommended route on Windows is the Python install manager.
- Install it from the Microsoft Store (search for "Python install manager") or from python.org/downloads.
- Open PowerShell (press the Windows key, type
powershell, press Enter). - Install 3.12:
py install 3.12- Check it:
py -V:3.12 --versionpy is the install manager's command. -V:3.12 picks version 3.12 when you have more than one. On Windows, wherever this page says python3.12, type py -V:3.12 instead.
The older route, the full installer from the Python 3.12.10 release page, also works. If you use it, tick Add python.exe to PATH on the first screen; without it, the terminal cannot find Python.
macOS
Either download the macOS 64-bit universal2 installer from the Python 3.12.10 release page and double-click it, or, if you already use the Homebrew package manager:
brew install python@3.12Linux
Ubuntu 24.04 LTS already comes with Python 3.12 as python3. You need one more package to make virtual environments:
sudo apt install python3-venvOther Linux systems: install python3.12 with your system's package manager.
3. Open a terminal and check
A terminal is a window where you type commands instead of clicking. On macOS, open Terminal (in Applications, then Utilities). On Windows, use PowerShell. On Linux, your desktop has a Terminal application.
Type this and press Enter (Windows: py -V:3.12 --version):
python3.12 --versionYou should see
Python 3.12.15The last number may be different (3.12.10, for example). Anything starting 3.12 is right.
4. The interactive prompt
Type python3.12 on its own (Windows: py -V:3.12) and press Enter. The prompt changes to >>>: Python is now waiting for one line at a time and answers each one straight away. This is the REPL (read, evaluate, print, loop), taught in Module 1 Lesson 2.
>>> 2 + 3
5
>>> print("Hello from the Booknook shelf")
Hello from the Booknook shelf
>>> exit()exit() leaves the prompt and gives you the terminal back. Python 3.13 and later have a newer prompt, with colour and easier multi-line editing, where exit also works without the brackets. Python 3.12's prompt is plainer. Lessons say which one a figure shows.
5. A code editor
You can write Python in any plain-text editor, but a code editor colours the code, shows mistakes as you type, and runs files with one click. Two free choices:
| Editor | Good for | Get it |
|---|---|---|
| Visual Studio Code | The editor most working programmers use; grows with you | code.visualstudio.com, then install the Python extension from Microsoft inside it |
| Thonny | Complete beginners; simple and uncluttered | thonny.org |
In VS Code, open a folder with File, then Open Folder, and choose your Python with Python: Select Interpreter from the Command Palette (Ctrl+Shift+P, or Cmd+Shift+P on a Mac).
6. Run a script
A script is a file of Python code that runs from top to bottom. Make a folder for the course, create a file in it called hello.py in your editor, and put this one line in it:
print("Hello from a script")Save it. In the terminal, move into that folder with cd (for example cd Documents/booknook-course) and run:
python3.12 hello.pyYou should see
Hello from a scriptThis is exactly what %%writefile hello.py followed by !python hello.py did in Colab (02-setup-colab.md, section 5): the first writes the file, the second runs it.
7. The project folder and a virtual environment
From Module 7 you build one project, booknook. A virtual environment (venv) is a private copy of Python for one project, with its own installed packages, so that one project's packages never break another's. Module 7 Lesson 4 explains why; these are the steps.
Make the folder and move into it:
mkdir booknook
cd booknookCreate the virtual environment, in a folder called .venv:
python3.12 -m venv .venvActivate it, which tells this terminal to use the project's private Python:
| System | Command |
|---|---|
| macOS and Linux | source .venv/bin/activate |
| Windows (PowerShell) | .venv\Scripts\Activate.ps1 |
The prompt now starts with (.venv). While it does, python means the project's Python, whatever version number you typed to create it:
(.venv) $ python --version
Python 3.12.15To leave the environment, type deactivate. Activate it again each time you open a new terminal for the project.
On Windows, if PowerShell says running scripts is disabled, run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once, answer Y, and activate again.
8. Install packages with pip
pip installs packages from PyPI, the Python Package Index. The project's requirements.txt (written in Module 7) lists the one package it needs, with its version pinned:
pytest==9.1.1With the environment active, install everything listed in it:
python -m pip install -r requirements.txtThen see what is installed:
python -m pip listThe list includes pytest 9.1.1 and the few small packages pytest needs (and pip itself). Always type python -m pip, not just pip: it guarantees the package goes into the Python you are actually using.
9. Run the tests and the tool
From Module 10, with the environment active and the terminal in the booknook folder:
python -m pytest -qpytest finds every file in tests/ whose name starts with test_, runs the tests in it, and prints a dot for each one that passes and a summary line such as 15 passed. Module 10 Lesson 4 explains the output.
From Module 11, the finished tool runs the same way:
python -m booknook report10. From notebook cells to your own computer
| In Colab | On your own computer |
|---|---|
%%writefile booknook/fees.py and the code | Create booknook/fees.py in your editor and paste the code in |
%%ensure booknook/fees.py in a lab | The same, but only if you do not have the file already. Never replace your own work |
!python hello.py | python hello.py in the terminal |
%pip install -q pytest==9.1.1 | python -m pip install -r requirements.txt inside the venv |
%cd booknook | cd booknook |
| The catch-up cell | Not needed: your files stay where you saved them |
input() shows a box under the cell | input() waits for you to type in the terminal |
11. When something goes wrong
| What you see | What it means | What to do |
|---|---|---|
'python3.12' is not recognized (Windows) | Windows uses a different command | Use py -V:3.12 instead |
command not found: python3.12 (macOS, Linux) | 3.12 is not installed, or is under another name | Check with python3 --version; if that says 3.12, use python3 |
No module named pytest | pytest went into a different Python, or the venv is not active | Activate the venv (look for (.venv)), then python -m pip install -r requirements.txt |
ModuleNotFoundError: No module named 'booknook' | The terminal is not in the project folder | cd into the outer booknook folder, the one that holds data/ and tests/ |
Activate.ps1 cannot be loaded because running scripts is disabled | A Windows safety setting | See the note at the end of section 7 |
| Your output differs from the lesson's | Usually a different Python version, or a cell's code that changed | Check python --version; then compare your code with the lesson's line by line |
The next step after this course is version control with Git, which keeps the history of every change to the repository. It is not covered here; Module 1 of the AI Engineering course has a lesson on it.