Set up once¶
The goal is a fresh clone that behaves like everyone else's fresh clone. An environment is not bureaucracy; it is how “works on my machine” becomes a testable statement.
Recommended path: uv¶
Install uv using its
official instructions.
Then:
git clone https://github.com/comphy-lab/comphy-python101.git
cd comphy-python101
uv sync --all-extras
uv reads pyproject.toml, installs the Python version named in
.python-version, and recreates the dependency versions recorded in
uv.lock.
Run the smoke checks:
The summary should be JSON with 16 samples and a final time of 0.75. The test suite should pass.
Plain Python path¶
Python 3.11 or newer is sufficient.
Use python -m pip, not a bare pip, when you are unsure which interpreter a
command belongs to.
Read a command as a sentence¶
uv runselects the project environment.pythonexecutes a Python file.examples/reproduce_capsule.pyis the program.--output build/capsuleis an explicit input to that program.
The shell is not outside programming. Paths, arguments, exit status, and working directory are part of the computation.
The full capsule front door adds environment, tests, a clean rebuild, and checksum verification around that explicit program:
Your editor¶
Use any editor that can:
- show line numbers;
- display the selected Python interpreter;
- search across the repository;
- open a terminal in the project root.
Visual Studio Code, PyCharm, and a terminal editor all work. Do not spend the first hour polishing an editor theme. Make the smoke test pass.
Common setup failures¶
command not found¶
The shell cannot locate the executable. Check installation and restart the terminal before changing code.
ModuleNotFoundError¶
Usually the wrong interpreter is active or dependencies were not installed.
which python # macOS / Linux
where.exe python # Windows
python -c "import sys; print(sys.executable)"
A relative path cannot be found¶
Check:
Run course commands from the repository root unless the exercise says
otherwise. Later, you will make tools independent of the caller's working
directory with pathlib.
Matplotlib cannot open a display¶
Batch and CI machines have no desktop. Scientific scripts should save figures, not require a window. The reference plotting functions do exactly that.
Final check¶
Build the website locally:
Open the displayed local URL. If code tests and the site build both work, the environment is ready.