| name | uv |
| description | uv — Python package manager, dependency management, virtual environments, and script running. Replaces pip, pip-tools, virtualenv, pyenv. |
uv
Project setup
uv init my-project
cd my-project
uv venv
uv venv --python 3.10
Dependency management
uv add torch numpy pandas
uv add --dev pytest ruff pyright
uv add --optional baselines lightning transformers
uv remove numpy
uv add --upgrade numpy
uv sync
uv sync --all-extras --dev
uv pip install some-package
Running code
uv run python script.py
uv run python -m module.name
uv run pytest tests/
uv run ruff check .
uv run pyright
uvx ruff check .
uvx library-skills --claude
uvx cookiecutter https://github.com/...
Lock file
uv lock
uv lock --upgrade
Python version management
uv python install 3.10 3.11
uv python pin 3.10
uv python list
uv.sources — custom index / local path
[tool.uv.sources]
torch = { index = "pytorch" }
my-local-pkg = { path = "../my-local-pkg", editable = true }
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"
explicit = true
Pitfalls
- Never use bare
pip install or python in a uv-managed project — always prefix with uv run or uv pip.
uv sync installs exactly what is in uv.lock; uv add resolves and updates the lock. Don't mix them carelessly.
uv pip install skips pyproject.toml update — only use for ephemeral/system installs.
- Commit both
pyproject.toml and uv.lock to git for reproducible environments.
uvx runs tools in isolated ephemeral envs — don't use it for project-level tools that need the project venv.