Installing Python
A short guide using uv
Why we use uv for this course
uv is a new (and very fast) Python tool written in Rust. It: - Installs Python for you (no manual downloads). - Creates isolated virtual environments (safe sandboxes per project). - Installs and updates packages quickly.
WHAT is a virtual environment? Think of each project as its own coffee shop with its own supplies. One shop changing its menu does not affect the others. WHY it matters: You avoid random breakage when different projects need different versions of the same package.
Install uv
Choose the instructions for your operating system.
macOS or Linux (Terminal)
curl -LsSf https://astral.sh/uv/install.sh | shIf curl is missing:
wget -qO- https://astral.sh/uv/install.sh | shAfter installation: close and reopen your terminal (so your PATH updates).
Windows (PowerShell)
Open PowerShell and run:
powershell -ExecutionPolicy Bypass -c "irm https://astral.sh/uv/install.ps1 | iex"If you see a script execution warning, you can alternatively first run:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope ProcessThen re-run the install line.
Verify installation
Run (macOS / Linux / Windows):
uv --versionIf you see a version number: great!
If you get “command not found” or “‘uv’ is not recognized”:
- Close and reopen the terminal (important).
- On Windows: make sure you used PowerShell (not Command Prompt).
- Still broken? Ask for help, no need of guessing the error.
InstallPython
We want everyone on the same Python version for consistency. Thus, we’ll use Python 3.12 for the course this year.
Install (you only need to do this once):
uv python install 3.12Check the installation:
uv run python --versionExpected output starts with:
Python 3.12.
Create your first project
Pick a folder where you keep course work. If you do not have one, make sure to create one! Open the course folder in your IDE and then run the following from the terminal:
uv init my-first-project
cd my-first-projectThe first line creates a new folder named my-first-project (you can name it anything). The second line moves you into that folder. Alternatively, you can create the folder manually before, open it in your IDE and run uv init . inside it.
uv init creates: - main.py (starter script) - pyproject.toml (project + dependencies config) - .python-version (records the Python version we chose) - .gitignore (useful if you ever use Git) - README.md (you can jot notes here) - (A .venv folder will appear later once packages are added or synced.)
You do not need to edit any of these (except maybe README.md for your notes and main.py if you want to run something different).
Run the starter script
Inside the project folder:
uv run python main.pyYou should see something like:
Hello World!
(If you want, you can open main.py and change the message, then re-run.)
What does that code mean?
def main():
print("Hello, World!")
if __name__ == "__main__":
main()def main():defines a function (a reusable block of code).print(...)shows text in the terminal.- The line
if __name__ == "__main__":ensures this only auto-runs when the file is executed directly.
Don’t worry about this yet, we’ll gradually build up to it.
Adding packages (later in the course)
If/when you need a package (example: pandas):
uv add pandasIf you added the wrong one:
uv remove pandasIf your pyproject.toml changed (e.g. you pulled code from someone else):
uv syncIf something seems “off”, just close the terminal and reopen in the project folder. Fresh starts fix many early mistakes.
Updating uv
Occasionally:
uv self update(If it ever errors, you can just reinstall using the same one-liner from earlier.)
Best practices for this course
- One folder for the course keeps everything tidy.
- Never install packages “globally” outside a project.
- Keep a short personal log in each project’s
README.md(What did I do? What still confuses me?). - Ask early for help, guessing usually takes much more time than asking.
You can always see available commands:
uv --helpRecap
You can now: 1. Install uv. 2. Create a project. 3. Run a script. 4. Add/remove/sync packages.
Now, you’re set to continue the course.