curl -LsSf https://astral.sh/uv/install.sh | sh★Standalone installer, macOS/Linux. No Python or Rust needed.powershell -c "irm https://astral.sh/uv/install.ps1 | iex"Windows equivalent.pip install uv·brew install uvAlso on PyPI, Homebrew, Scoop, WinGet, Docker, and as a GitHub Action.uv self update★Upgrade uv in place (standalone installs only).uv --version·uv helpVersion + full CLI reference in the terminal.
uv init myapp★Scaffold:pyproject.toml,main.py,README.md,.python-version, git.uv initInitialize in the current directory.uv init --lib mylib★A packaged library (src layout + build backend) instead of an app.uv init --app·--packageApp (default) vs a packaged app you can publish.uv init --bareJust apyproject.toml— no sample files, no README, no VCS.uv init --python 3.13Pin the project's Python at creation.
uv add httpx★Resolve, updatepyproject.toml+uv.lock, install into.venv— all at once.uv add "httpx>=0.27,<1"Any PEP 508 spec: version ranges, extras, markers.uv add --dev pytest ruff★Into thedevgroup under[dependency-groups]— not shipped to users.uv add --group docs sphinxA named dependency group (PEP 735).--optional NAMEfor an extra instead.uv add --editable ../mylibA local path dep, editable. Also--git URL,--branch,--tag.uv add --bounds major httpxControl the written constraint style:>=0.28,<1.0style bounds.uv remove httpx★Drop it from all three files.--dev/--groupto target a group.
uv run python main.py★Verifies lock + venv are current, then runs. No activate needed.uv run pytest·uv run ruff check★Any entry point installed in the env.uv run -- flask run -p 3000Use--so flags reach your command, not uv.uv run --with rich script.py★Add a one-off dependency for this run only — not written to the project.uv run --no-sync pythonSkip the auto-sync check — faster when you know the env is fresh.uv run --env-file .env python app.pyLoad env vars from a file before running.
uv lock★Resolve the whole project intouv.lockwithout installing.uv lock --upgrade★Re-resolve to newest allowed versions.--upgrade-package httpxfor just one.uv sync★Make.venvexactly matchuv.lock— installs missing, removes extra.uv sync --frozen★Install from the lock as-is; error if it's stale. The CI/production install.uv sync --lockedAssert the lock is already up to date, then sync — fails ifpyprojectdrifted.uv sync --all-extras --all-groupsPull in every optional extra and group.--no-devto exclude dev.uv lock --checkCI guard: exit non-zero if the lockfile is out of date.
uv tree★The project's dependency tree.--depth 1,--package httpxto focus.uv tree --invertWho depends on this? — trace a transitive dep back up.uv export --format requirements-txt -o requirements.txt★Emit a classic pinnedrequirements.txtfrom the lock (with hashes).uv export --no-hashes --no-devTrim for a slim runtime requirements file.uv version·uv version --bump minorRead or bump the project's own version (patch/minor/major).
pyproject.toml★Your declared requirements & config. Commit it. Hand-edit or useuv add.uv.lock★Exact, cross-platform, hashed resolution. Commit it. Never hand-edit..venv/★The real environment. Git-ignore it — it's rebuilt from the lock..python-versionThe project's default Python. Written byuv python pin.[tool.uv] in pyproject.tomluv-specific config:[tool.uv.sources], index URLs, resolution knobs.