UV is a Python package manager and project tool. This Cheatsheet covers installation, project management, dependency handling, and more.
|
Linux & macOS
|
||
|
curl -LsSf https://astral.sh/uv/install.sh | sudo sh
|
||
|
Windows (PowerShell)
|
||
|
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
||
|
Homebrew (macOS)
|
||
|
brew install uv
|
||
|
Basic Commands
|
||
|
Check Installed Version
|
||
uv version |
||
|
Get Help
|
||
uv help uv --help |
||
|
Project Initialization
|
||
|
Create a New Project
|
||
uv init project-name # Basic project |
|
uv init — initialize project (creates pyproject.toml, .venv)
|
|
uv add [pkg], --dev — add dependencies
|
|
uv lock, uv sync — lock & sync to universal uv.lock file gist.github.com docs.astral.sh +3 horoscopo-astral.com +3 docs.astral.sh +3 docs.astral.sh +1 docs.astral.sh +1
|
|
uv venv [--python X.Y] — create venv (downloads Python if missing)
|
|
uv python install …, uv python pin X.Y — install and pin Python versions
|
|
Inline script metadata (# /// script …) for dependencies & Python version
|
|
uv run --script …, uv add --script …, uv lock --script … for isolated script execution
|
|
uvx <tool> … – run tools in ephemeral envs
|
|
uv tool install <tool> – globally install tools like pipx
|
|
uv pip install, sync, compile, freeze, show, tree, etc. — speedier, pip-compatible
|
|
uv.lock (universal) captures exact package versions across platforms
|
|
.lock next to script for script-specific dependencies
|
|
uv self update, uv cache clean/prune, uv python dir, uv tool dir, shell completions
|
requirements.txt.No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.