Show Menu
Cheatography

UV Cheatsheet Keyboard Shortcuts by

UV is a Python package manager and project tool. This Cheatsheet covers installation, project management, dependency handling, and more.

Instal­lation

Linux & macOS
Windows (Power­Shell)
powershell -Execu­tio­nPolicy ByPass -c "irm https:­//a­str­al.s­h/­uv/­ins­tal­l.ps1 | iex"
Homebrew (macOS)
brew install uv
Basic Commands
Check Installed Version
uv version
Get Help
uv help uv --help
Project Initia­liz­ation
Create a New Project
uv init projec­t-name     # Basic project

Project Management

uv init — initialize project (creates pyproj­ect.toml, .venv)
uv add [pkg], --dev — add depend­encies
uv lock, uv sync — lock & sync to universal uv.lock file gist.g­ith­ub.com docs.a­str­al.sh +3 horosc­opo­-as­tra­l.com +3 docs.a­str­al.sh +3 docs.a­str­al.sh +1 docs.a­str­al.sh +1
 

Virtual Enviro­nments

uv venv [--python X.Y] — create venv (downloads Python if missing)
uv python install …, uv python pin X.Y — install and pin Python versions

Script Support

Inline script metadata (# /// script …) for depend­encies & Python version
uv run --script …, uv add --script …, uv lock --script … for isolated script execution

Tool Execution

uvx <to­ol> … – run tools in ephemeral envs
uv tool install <to­ol> – globally install tools like pipx

pip-Co­mpa­tible Interface

uv pip install, sync, compile, freeze, show, tree, etc. — speedier, pip-co­mpa­tible

Lockfiles

uv.lock (unive­rsal) captures exact package versions across platforms
.lock next to script for script­-sp­ecific depend­encies
 

Extras & Utilities

uv self update, uv cache clean/­prune, uv python dir, uv tool dir, shell comple­tions

Typical Workflow

 
uv init myproj # start project
uv add requests --dev # add depend­encies
uv lock # generate uv.lock
uv sync # sync venv
uv run pytest # run tests in enviro­nment
uv tool install black # globally install tools
uv pip compile reqs.in # generate platfo­rm-­ind­epe­ndent reqs
uv pip sync reqs.txt # sync enviro­nments
       
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          SISTEMAS DE ALMACENAMIENTO NAS vs SAN Cheat Sheet