Kiru Lab / Foundations: Python as an Instrument / Getting Set Up
Installing Python and an Editor
Thirty minutes of setup that removes every excuse for the next thirty tracks. Do it once, properly.
Hands-On Lab · about 45 minutes
You need three things: the Python interpreter, a place to write text, and a terminal to run commands in. That is the whole toolchain. People make this sound complicated because they are describing their own accumulated preferences rather than the requirement.
Step 1 — Install Python
- Go to python.org/downloads and install the current stable release (3.11 or newer). On Windows, tick "Add python.exe to PATH" on the first screen — this is the step everyone skips and then spends an hour debugging.
- On macOS, the Python that ships with the system is old and should be left alone. Install a fresh one from python.org or via Homebrew.
- On Linux, your package manager already has it: `sudo apt install python3 python3-pip python3-venv` on Debian or Ubuntu.
Step 2 — Open a terminal and confirm
The terminal is a window where you type commands instead of clicking. On Windows it is called Terminal or PowerShell; on macOS, Terminal; on Linux, whatever your desktop calls it. Open it and type this, then press Enter:
python3 --version
# Python 3.12.1 <- some version number, 3.11 or higher
# On Windows this may be:
python --versionIf you get a version number, you are done with the hard part. If you get "command not found", Python is installed but the terminal does not know where — on Windows that is the PATH checkbox from step 1, and reinstalling with it ticked is faster than fixing it by hand.
Step 3 — Install an editor
Install Visual Studio Code from code.visualstudio.com, then install its Python extension from the Extensions panel. You could use any text editor — the file is just text — but VS Code will underline your mistakes before you run the program, and when you are starting out that feedback is worth a great deal.
Step 4 — Make a folder and a virtual environment
A virtual environment is a private copy of Python for one project, so the packages you install for this curriculum cannot break anything else on your machine. Make one now and use it for the whole lab.
mkdir kiru-lab
cd kiru-lab
python3 -m venv .venv # create it (once)
# Activate it (every time you open a new terminal):
source .venv/bin/activate # macOS / Linux
.venv\Scripts\activate # Windows
# Your prompt now starts with (.venv). Install what the lab needs:
pip install numpy matplotlibIf a command fails, read the last line of the output before doing anything else. It almost always names the problem — a missing package, a wrong path, a typo. Reaching for a search engine before reading the error is the most expensive habit in programming, and it is easiest to avoid before you have formed it.
Hold on to
- Python, an editor, and a terminal — that is the whole toolchain
- A virtual environment keeps this project's packages isolated
- Read the last line of an error before doing anything else
Work through
Try each one before opening the solution. Getting it wrong first is most of where the learning happens.
-
Install Python and confirm the version from a terminal. Write down the exact command that worked on your machine — it differs by platform and you will type it hundreds of times.
Hint
On Windows the command is usually `python`; on macOS and Linux it is usually `python3`.
Solution
Either command is correct — which one works depends on your platform and how Python was installed. Write down the one that worked, because every later instruction in this lab assumes you know which you are using.
# macOS / Linux python3 --version # Windows python --version # Both should print 3.11 or higher. -
Create the `kiru-lab` folder, make a virtual environment, activate it, and install numpy. Confirm with `pip list` that numpy appears.
Hint
Create the environment once; activate it every time you open a new terminal.
Solution
After activating, your prompt is prefixed with (.venv). `pip list` inside the environment shows a short list — pip, setuptools, and whatever you installed — rather than everything on your system.
mkdir kiru-lab && cd kiru-lab python3 -m venv .venv source .venv/bin/activate # .venv\Scripts\activate on Windows pip install numpy pip list # numpy should appear -
Deactivate the environment (`deactivate`), then run `pip list` again. Explain in one sentence what changed and why that is the point of a virtual environment.
Hint
Compare the two package lists, not just their lengths.
Solution
Deactivated, `pip list` shows your system Python's packages and numpy is either absent or a different version. That is the point: the environment is a sealed box, so installing something for this project cannot break another project or your operating system's own Python. Every project you ever work on should have one.
Sign in to track your progress through the lab.