Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

uv cheatsheet

Manage python version (replaces pyenv)

PurposeCommand
Install a specific Python versionuv python install <version>
List available Python versionsuv python list
Use a specific Python version in a projectuv python use <version>
Automatically install the required Python versionuv run --python <version> script.py
Pin the Python version for a projectuv python pin

Manage environment (replaces venv)

PurposeCommand
Create a virtual environmentuv venv
Create a virtual environment with specific Python ver.uv venv --python <version>
Activate virtual environment (Linux/macOS)source .venv/bin/activate
Activate virtual environment (Windows).venv\Scripts\activate
Remove a virtual environmentuv remove
Reinstall all dependencies in the virtual environmentuv sync --reinstall

Manage project (replaces poetry)

PurposeCommand
Initialize a new projectuv init <project-name>
Add a package as a dependencyuv add <package-name>
Add a dev dependencyuv add --dev <package-name>
Add a package from Gituv add git+https://github.com/user/repo.git
Remove a packageuv remove <package-name>
Lock dependencies to exact versionsuv lock
Upgrade a specific package only on uv.lockuv lock --upgrade-package <package-name>
Upgrade all dependencies only on uv.lockuv lock --upgrade
Build a Python packageuv build
Publish a package to PyPIuv publish

Manage packages (replaces pip, pipx)

PurposeCommand
Install a packageuv add <package-name>
Remove a packageuv remove <package-name>
Install dependencies from pyproject.tomluv sync
Install dependencies while excluding some groupsuv sync --no-group dev --no-group lint
Install dependencies from requirements.txtuv pip install -r requirements.txt
Freeze dependencies into requirements.txtuv pip freeze > requirements.txt
Generate requirements.txt from uv.lockuv export --format requirements-txt > requirements.txt
Upgrade only the uv.lock fileuv lock --upgrade
Upgrade all packages (uv.lock and execution)uv sync --upgrade
Upgrade a single package (uv.lock and execution)uv sync --upgrade-package <package-name>
Install CLI tools globallyuv tool install <tool-name>
List all installed toolsuv tool list
Remove a globally installed CLI tooluv tool uninstall <tool-name>
Upgrade all installed CLI toolsuv tool upgrade --all

Manage scripts (replaces python tools)

PurposeCommand
Run a Python script inside the virtual environmentuv run <script.py>
Run a script while automatically installing depsuv run --with <package> python script.py
Run a command inside the virtual environmentuv run -- <command>
Run a one-time CLI tool without installing globallyuvx <tool-name> --version
Install a tool globallyuv tool install <tool-name>
Upgrade a specific tooluv tool upgrade <tool-name>
Upgrade all installed toolsuv tool upgrade --all
Enable shell auto-completion for uveval "$(uv generate-shell-completion bash)"

Attribution