Setting up your ML repo

2026-02-02

This is part of a series on ML for generalists, you can find the start here.

I'm a fan of uv from Astral for managing Python projects. It takes care of package management, Python versions and virtual environments. Use whatever you prefer, but the commands below assume uv.

Create your project:

uv init whichway

Then add the dependencies we'll need:

uv add numpy pillow torch torchvision

What these are:

If you're on an older Intel Mac like me, you might hit compatibility issues with the latest versions (binary builds aren't available for newer releases).

Here's what worked for me in pyproject.toml and use Python 3.12:

uv python pin 3.12
# pyproject.toml
requires-python = ">=3.12"
dependencies = [
    "numpy<2",
    "pillow>=12.0.0",
    "torch==2.2.2",
    "torchvision==0.17.2",
]

Activate your environment (or prefix commands with uv run) and check everything installed correctly:

uv run python -c "import torch; import torchvision; print('packages are installed')"

If that prints without errors, you're good to start generating data.