Part 0 · Orientation · Module 00
Setup: Python 3.14 with Pixi
Before you can learn to program, you need a place to run programs. In this module you will learn how this course works, install Pixi, use it to get Python 3.14, and run your very first script. Every professional Python developer does this same setup, so nothing here is "just for beginners".
- Use this course effectively: read, run, predict, practise, quiz, build
- Explain what a package manager and an environment are, and why we use Pixi
- Install Pixi on macOS, Linux, or Windows and create a workspace with Python 3.14
- Read a
pixi.tomlfile and run code withpixi run,pixi shell, and tasks - Clone this course, serve it locally, and start and grade a project
- Use the Python 3.14 REPL and an editor, and write and run a first script
- Read an error message calmly and use it to fix your code
How to use this course
Welcome! This course is designed for active learning. Research on learning is very clear on one point: you remember what you do far better than what you only read. So every page asks you to do something every few minutes. Here is the rhythm each module follows:
- Read a short explanation of one idea. Every new term is defined the first time it appears.
- Run the example. Code boxes with a Run button execute real Python 3.14 right in your browser (using a technology called Pyodide, which is CPython compiled to run inside a web page). You can edit the code and run it again. Breaking things is encouraged; you cannot damage anything.
- Predict before you run. Boxes marked "Predict the output" ask you to type what you think the program will print, then compare with reality. Wrong guesses are the most valuable moments in learning, because they show you exactly where your mental model differs from how Python really works.
- Exercise. In the Practice section you write code that is checked automatically by tests. A test is a small piece of code that checks whether your code behaves correctly.
- Quiz. A short quiz at the end of every module checks your understanding. Each answer comes with an explanation, so read them even when you are right.
- Mini-project. A small program you build on your own computer with Pixi, with a checklist of acceptance criteria (the conditions that mean "done").
- Part project. Each part of the course ends with a larger graded project that combines
everything from that part. You start it with
pixi run start p01and grade it withpixi run grade p01(you will set this up below).
Your progress is saved in your browser
Quiz scores, exercise results, checklists, and "Mark complete" buttons are saved in your browser's local storage. That means there is no account and no server; your data stays on your computer. It also means that if you switch browsers or clear your browser data, the progress is gone. To keep a backup, use the Export progress button on the home page; it downloads a small JSON file. Import progress on the same page loads it back, for example on another computer.
The notes box
At the bottom of every page there is a My notes box. Use it! Write what you learned in your own words, what confused you, and questions to come back to. Explaining an idea in your own words is one of the most effective ways to learn it. Notes are saved in the browser too and are included in the export.
Try your first runnable cell now. Press Run. Then change the text between the quotes and run it again.
The second line looks a bit mysterious right now. That is fine: you will understand every part of it by the end of
Part 1. For now, notice that it reports a version starting with 3.14.
Package managers and environments
The browser cells are great for experiments, but real programs live in files on your computer. To run them you need Python installed. Before installing anything, let us understand two words you will hear constantly.
What is a package?
A package is a bundle of code someone else wrote so that you do not have to. Python itself
comes with a big standard library (math, dates, files, and much more), but there are hundreds of
thousands of extra packages: numpy for numbers, pandas for tables, pytest
for testing. Even Python itself is distributed as a package.
What is a package manager?
A package manager is a program that downloads packages, installs them in the right place, and makes sure the versions fit together. Packages depend on other packages (these are called dependencies), and those depend on yet others. Working out a set of versions that are all compatible is called dependency resolution, and it is a hard problem that you want a tool to solve for you.
What is an environment?
An environment is a folder containing one particular Python interpreter plus one particular set
of packages. Why not just install everything once, globally? Because projects disagree. Your data project might
need pandas 2 while an old script needs pandas 1. If both share one installation,
upgrading for one breaks the other. With one environment per project, each project gets exactly what
it needs and nothing leaks between them.
Why Pixi?
This course uses Pixi as its one and only tool for installing Python, installing packages, and running code. Pixi gives you:
conda-forge
Packages come from conda-forge, a huge community-maintained collection of pre-built packages, including Python itself and libraries written in C, C++, Fortran, and Rust. No compilers needed.
Per-project environments
Every project folder gets its own environment in a hidden
.pixi/ folder. Delete the folder and it is gone; nothing else on your system changes.
Lockfiles
pixi.lock records the exact version of every package. Anyone who
clones your project gets the identical environment: "it works on my machine" becomes "it works on every
machine".
Tasks
Named commands such as pixi run test or pixi run serve
live in pixi.toml, so you never have to remember long command lines.
Remember: a package manager installs code; an environment is an isolated folder of interpreter plus packages; Pixi gives each project its own environment, locked to exact versions.
Installing Pixi
You will type commands into a terminal (also called a shell or command line): a text window where you type a command, press Enter, and the computer prints a response. On macOS open the Terminal app; on Linux open your terminal emulator; on Windows open PowerShell from the Start menu. In this course, lines in a box labelled "Terminal" are commands you type.
curl -fsSL https://pixi.sh/install.sh | bash
curl downloads the installer script and | bash (a "pipe") hands it to the shell to
run. It installs Pixi into ~/.pixi/bin and adds that folder to your PATH, the list of
folders your shell searches for programs.
powershell -ExecutionPolicy Bypass -c "irm -useb https://pixi.sh/install.ps1 | iex"
irm (Invoke-RestMethod) downloads the installer and iex (Invoke-Expression) runs it.
-ExecutionPolicy Bypass allows this one script to run.
Close the terminal and open a new one so it picks up the new PATH. Then check that
it worked:
pixi --version
You should see something like pixi 0.x.y. If instead you see "command not found", the new terminal
did not pick up the PATH change yet: open another fresh terminal, or log out and back in.
Your first Pixi workspace
A workspace is a project folder that Pixi manages. Let us make one called hello.
pixi init hello
cd hello
pixi add python=3.14
Line by line: pixi init hello creates a folder hello containing a starter
pixi.toml. cd hello ("change directory") moves your terminal into that folder.
pixi add python=3.14 asks Pixi to add Python 3.14 as a dependency; Pixi resolves versions, downloads
Python from conda-forge, creates the environment, and writes the lockfile. The first time takes a minute; after
that Pixi reuses its download cache.
Anatomy of pixi.toml
pixi.toml is the workspace manifest: a file that declares what the project needs. It
is written in TOML ("Tom's Obvious Minimal Language"), a simple format made of [tables] (section
headers in square brackets) and key = value lines. After the commands above it looks like this:
[workspace]
authors = ["Ada Lovelace <ada@example.com>"]
channels = ["conda-forge"]
name = "hello"
platforms = ["osx-arm64"]
version = "0.1.0"
[tasks]
[dependencies]
python = "3.14.*"
[workspace]holds metadata.channelsare where packages come from (conda-forge).platformslists the operating systems and CPU types the lockfile supports; yours will match your computer, such aslinux-64,osx-arm64(Apple Silicon Macs), orwin-64.[dependencies]lists the packages you asked for."3.14.*"means "any 3.14 release", so you automatically get bug-fix releases such as 3.14.1, 3.14.2.[tasks]holds named commands; it is empty for now.
Files Pixi created
pixi.lock: the lockfile. It records the exact version and download address of every package, including dependencies of dependencies. You do not edit it by hand. Commit it to version control so collaborators get the identical environment..pixi/: the actual environment lives in.pixi/envs/default/. It is disposable; Pixi can rebuild it from the lockfile at any time, so it is listed in.gitignore.
Running Python
pixi run python --version
pixi run python -c "print('hi from 3.14')"
pixi run means "run this command inside the workspace's environment". If the environment is missing
or out of date, Pixi fixes that first. You can also open a shell where the environment is activated, so
plain commands use it, and leave it with exit:
pixi shell
python --version # inside pixi shell, this is the workspace's Python
exit
Tasks
Add a task so that one short word runs a longer command:
pixi task add hello "python hello.py"
pixi run hello
This adds hello = "python hello.py" under [tasks]. (It fails until you create
hello.py; we do that in a moment.)
Global tools
Some programs are tools you want everywhere, not dependencies of one project. pixi global install
installs a tool into its own private environment and puts its command on your PATH:
pixi global install git
pixi global list
Test your understanding of the manifest. The cell below parses a pixi.toml with Python's built-in
tomllib module and prints what Pixi would see. Predict the last line first.
Remember: pixi init creates a workspace, pixi add adds dependencies,
pixi run runs commands in the environment, pixi.lock pins exact versions, and
.pixi/ is disposable.
Getting this course on your computer
This course is itself a Pixi workspace. You get a copy with git, the version-control tool professionals use to track changes to code. Cloning means downloading a full copy of a repository (a project tracked by git).
git clone https://github.com/millsks/python-practicum.git
cd python-practicum
pixi install
pixi install builds the environment from the lockfile without running anything. It installs Python
3.14 and every library the course uses (numpy, pandas, pytest, and more), so expect it to take a few minutes the
first time.
The course helpers
| Command | What it does |
|---|---|
pixi run serve | Serves this website locally at http://127.0.0.1:8000 and
opens your browser. Press Ctrl+C in the terminal to stop it. |
pixi run projects | Lists every graded project and whether you have started it. |
pixi run start p01 | Copies Project 1's starter code into work/, where you
write your solution. |
pixi run grade p01 | Runs the project's tests against your code in work/ and
reports which pass. |
The Python 3.14 REPL
A REPL (Read–Eval–Print Loop) is an interactive Python prompt. It reads what you type, evaluates it, prints the result, and loops back for more. It is the fastest way to try a small idea. Start it from inside any workspace:
pixi run python
You will see a version banner and the prompt >>>. Type an expression and press Enter:
>>> 2 + 3
5
>>> "Py" * 3
'PyPyPy'
>>> for n in range(3):
... print(n)
...
0
1
2
The ... prompt means Python is waiting for more lines of a multi-line statement. Press Enter on an
empty line to finish it.
Handy REPL features
- Multi-line editing: press the Up arrow to recall a whole previous block (like the
forloop above) and edit it as one unit. - Leaving: type
exit(orquit) and Enter, or press Ctrl+D (macOS/Linux) / Ctrl+Z then Enter (Windows). - Help:
help(len)shows the documentation forlen;help()on its own starts an interactive help browser (typeqto leave a page,quitto leave help). Press F1 for help mode, F2 to browse history, F3 for paste mode. - The last result:
_holds the value of the last expression.
The browser cells behave much like a script rather than a REPL: only what you print is shown. Try
help here:
An editor and your first script
The REPL forgets everything when you exit. Real programs are saved in scripts: plain text files
ending in .py. You write them in a code editor, a text editor that understands code
(colors, autocompletion, error underlines).
VS Code setup
- Install Visual Studio Code (free) and, from its Extensions panel, the Python extension by Microsoft.
- Open your workspace folder: File → Open Folder… and choose
hello. - Open the Command Palette (Ctrl/Cmd+Shift+P), run Python: Select
Interpreter, and choose the one inside
.pixi/envs/default(on macOS/Linux.pixi/envs/default/bin/python; on Windows.pixi\envs\default\python.exe). Now the editor's autocompletion and error checks use exactly the Python thatpixi runuses.
Write and run hello.py
Create a file named hello.py in the hello folder with this content:
# My first Python script.
name = "world"
print(f"Hello, {name}!")
print("Python is adding:", 2 + 2)
pixi run python hello.py
pixi run hello # the task you added earlier
Python reads the file top to bottom and runs each line in order. Lines starting with # are
comments: notes for humans that Python ignores. Run the same script here and compare:
Reading error messages
Every programmer, from day one to year thirty, sees error messages every day. An error is not a sign that you are bad at this; it is Python telling you precisely what confused it. Learning to read errors calmly is the single most useful beginner skill.
When something goes wrong, Python prints a traceback: a report of where the program was when the error happened. Read it from the bottom up.
Traceback (most recent call last):
File "hello.py", line 3, in <module>
print(f"Hello, {nme}!")
^^^
NameError: name 'nme' is not defined. Did you mean: 'name'?
- The last line is the most important: the exception type (
NameError) and a message. Python even suggests a fix: did you meanname? - The lines above it show the file, the line number (
line 3), the line of code, and carets (^^^) pointing at the exact problem. - "most recent call last" means the deepest point of the program is at the bottom, closest to the error message.
| Error | Usually means |
|---|---|
SyntaxError | The code is not valid Python: a missing quote, bracket, or colon. Python refuses to run any of the file. |
NameError | You used a name that was never assigned, often a typo. |
TypeError | An operation got the wrong kind of value, such as "age " + 5. |
IndentationError | The spaces at the start of a line do not line up. |
Run this broken cell, read the traceback bottom-up, and fix it:
Remember: read tracebacks from the bottom; the last line names the problem, the lines above say where.
A peek at Python 3.15
Python releases a new version every October. While 3.14 is current, 3.15 is in development, and you can try it
without changing any project. pixi exec creates a temporary environment, runs one command in it, and
throws the environment away:
pixi exec --spec "python=3.15" python
Practice
Each exercise is checked by tests when you press Run. Read the test messages: they tell you what to fix.
Print exactly Hello, Pixi! (capital H and P, a comma, a space, and an
exclamation mark). Computers are literal: one wrong character and the test fails.
Hint
Everything between the quotes is printed as-is. Check capitals and punctuation.
Show solution
print("Hello, Pixi!")
Print exactly three lines, in this order: Name: Ada,
Learning: Python 3.14, and Tool: Pixi. Use one print per line.
Hint
Each print(...) call ends with a new line.
Show solution
print("Name: Ada")
print("Learning: Python 3.14")
print("Tool: Pixi")
This program has two bugs. Run it, read the traceback from the bottom, fix the first
error, then run it again to find the second. When fixed it prints Total: 10.
Hint
Python reports the SyntaxError (a missing closing
parenthesis) first, because it checks the whole file before running anything. Then look at the spelling of
pears.
Show solution
apples = 4
pears = 6
total = apples + pears
print("Total:", total)
Store the text of a valid pixi.toml in the variable
manifest_text. It must have a [workspace] table with name = "practice" and
channels = ["conda-forge"]; a [dependencies] table with python = "3.14.*";
and a [tasks] table with a task named hello that runs python hello.py.
The tests parse it with tomllib, just like Pixi would.
Hint
Every value goes under its table header. Strings need double quotes
and lists use square brackets: channels = ["conda-forge"].
Show solution
manifest_text = """
[workspace]
name = "practice"
channels = ["conda-forge"]
platforms = ["linux-64", "osx-arm64", "win-64"]
[dependencies]
python = "3.14.*"
[tasks]
hello = "python hello.py"
"""
Mini-project: your practice workspace
Quiz
Recap
- Learn actively: run every cell, predict before running, do the exercises, take the quiz, build the mini-project.
- Progress and notes live in your browser; export them from the home page to keep a backup.
- A package manager installs packages and resolves dependencies; an environment isolates one project's interpreter and packages.
- Pixi gives each workspace its own environment from conda-forge, pinned by
pixi.lock, with tasks inpixi.toml. pixi init,pixi add python=3.14,pixi run python file.py,pixi shell,pixi task add,pixi global install,pixi exec.- The REPL is for quick experiments; scripts are for programs you keep.
- Read tracebacks from the bottom up.
Going further
- Pixi documentation, especially "Getting started" and "Tasks"
- Pixi cheatsheet for this course
- Using the Python interpreter (official tutorial)
- What's new in Python 3.14 and the course's Python 3.14 reference
- VS Code Python tutorial
- Next: M01 · First Steps