uv 0.11.23
An extremely fast Python package and project manager written in Rust. A single tool replacing pip, pip-tools, pipx, poetry, pyenv, twine, virtualenv, and more — 10-100x faster than pip.
Overview
uv provides four main interfaces:
- Projects — Full project management with lockfiles, workspaces, and environments (
uv init, uv add, uv run, uv sync, uv lock)
- Scripts — Run Python scripts with on-demand dependency resolution, including inline metadata (PEP 723)
- Tools — Install and run CLI tools from Python packages, like
pipx (uvx, uv tool install)
- Python versions — Install and manage Python interpreters, auto-downloading as needed
It also includes a pip-compatible interface (uv pip install, uv pip compile, uv venv) for gradual migration from existing workflows.
Usage
Projects
# Create a new project
uv init my-project
# Add dependencies (auto-creates .venv, updates lockfile)
uv add requests flask
# Add with version constraints
uv add 'requests>=2.28,<3'
# Remove a dependency
uv remove requests
# Run commands in the project environment
uv run python main.py
uv run -- flask run -p 3000
# Lock dependencies (generates uv.lock)
uv lock
# Sync environment to match lockfile
uv sync
# Build distributions
uv build
# View dependency tree
uv tree
Scripts
# Run a script (auto-manages environment)
uv run script.py
# Run with ad-hoc dependencies
uv run --with rich,requests script.py
# Add inline metadata to a script (PEP 723)
uv add --script script.py requests
# Initialize a new script with metadata
uv init --script tool.py --python 3.12
# Lock script dependencies
uv lock --script script.py
Tools (like pipx)
# Run a tool in an ephemeral environment (alias: uvx)
uv tool run ruff check .
uvx ruff check .
# Run specific version
uvx ruff@0.9.0 check .
# Install a tool persistently (adds to PATH)
uv tool install ruff
# Upgrade tools
uv tool upgrade ruff
uv tool upgrade --all
# List installed tools
uv tool list
# Uninstall a tool
uv tool uninstall ruff
Python Versions
# Install Python versions
uv python install 3.12
uv python install 3.11 3.12 3.13
# Install PyPy
uv python install pypy@3.10
# List installed and available versions
uv python list
# Pin Python version for current directory
uv python pin 3.12
# Upgrade to latest patch
uv python upgrade 3.12
pip Interface (drop-in replacement)
# Create virtual environment
uv venv --python 3.12
# Install packages
uv pip install flask requests
# Compile requirements (like pip-compile)
uv pip compile requirements.in -o requirements.txt
# Sync environment to match requirements
uv pip sync requirements.txt
# Uninstall packages
uv pip uninstall flask
Common Flags
| Flag |
Description |
--python VERSION |
Use specific Python version (e.g., 3.12, pypy@3.10) |
--with PACKAGE |
Include additional packages (run/tool contexts) |
--no-project |
Skip project context, run standalone |
--system |
Install into system Python (CI/containers) |
--exclude-newer DATE |
Limit to distributions released before date |
Gotchas
uvx vs uv run for tools — uvx runs in an isolated environment. Use uv run when the tool needs access to your project (e.g., pytest, mypy).
- Package name vs command name — When they differ, use
--from: uvx --from httpie http.
- Inline script metadata ignores project deps — Scripts with
# /// script blocks run independently of the surrounding project. No need for --no-project.
- Automatic Python downloads — uv downloads Python on-demand by default. Disable with
UV_PYTHON_DOWNLOADS=never or --no-managed-python.
.venv naming — uv creates .venv by default. Use VIRTUAL_ENV=/path/to/venv to target a different environment.
- Lockfile format —
uv.lock is TOML-based and managed automatically. Do not edit it manually.
--system flag — Required when installing into non-virtual (system) Python. Skips virtualenv discovery.
References
- 01-projects — Project lifecycle: init, add, lock, sync, run, build
- 02-tools — Tool management: uvx, install, upgrade, list, uninstall
- 03-scripts — Script execution, inline metadata (PEP 723), shebangs
- 04-python-versions — Python installation, discovery, pinning, upgrades
- 05-pip-interface — pip-compatible commands: install, compile, sync, uninstall
- 06-workspaces — Multi-package workspace setup and management
- 07-resolution — Resolution strategies, constraints, overrides, indexes
1---2name: uv-0-11-233description: Manages Python packages, projects, scripts, tools, and Python versions with extreme speed. Use when the user mentions uv, python packages, pip replacement, virtual environments, venv, pyproject.toml, dependency management, python version switching, tool installation (uvx), script dependencies, lockfiles, workspace management, or any Python packaging task. Replaces pip, pip-tools, pipx, poetry, pyenv, twine, and virtualenv.4---56# uv 0.11.2378An extremely fast Python package and project manager written in Rust. A single tool replacing `pip`, `pip-tools`, `pipx`, `poetry`, `pyenv`, `twine`, `virtualenv`, and more — 10-100x faster than pip.910## Overview1112uv provides four main interfaces:13141. **Projects** — Full project management with lockfiles, workspaces, and environments (`uv init`, `uv add`, `uv run`, `uv sync`, `uv lock`)152. **Scripts** — Run Python scripts with on-demand dependency resolution, including inline metadata (PEP 723)163. **Tools** — Install and run CLI tools from Python packages, like `pipx` (`uvx`, `uv tool install`)174. **Python versions** — Install and manage Python interpreters, auto-downloading as needed1819It also includes a **pip-compatible interface** (`uv pip install`, `uv pip compile`, `uv venv`) for gradual migration from existing workflows.2021## Usage2223### Projects2425```bash26# Create a new project27uv init my-project2829# Add dependencies (auto-creates .venv, updates lockfile)30uv add requests flask3132# Add with version constraints33uv add 'requests>=2.28,<3'3435# Remove a dependency36uv remove requests3738# Run commands in the project environment39uv run python main.py40uv run -- flask run -p 30004142# Lock dependencies (generates uv.lock)43uv lock4445# Sync environment to match lockfile46uv sync4748# Build distributions49uv build5051# View dependency tree52uv tree53```5455### Scripts5657```bash58# Run a script (auto-manages environment)59uv run script.py6061# Run with ad-hoc dependencies62uv run --with rich,requests script.py6364# Add inline metadata to a script (PEP 723)65uv add --script script.py requests6667# Initialize a new script with metadata68uv init --script tool.py --python 3.126970# Lock script dependencies71uv lock --script script.py72```7374### Tools (like pipx)7576```bash77# Run a tool in an ephemeral environment (alias: uvx)78uv tool run ruff check .79uvx ruff check .8081# Run specific version82uvx ruff@0.9.0 check .8384# Install a tool persistently (adds to PATH)85uv tool install ruff8687# Upgrade tools88uv tool upgrade ruff89uv tool upgrade --all9091# List installed tools92uv tool list9394# Uninstall a tool95uv tool uninstall ruff96```9798### Python Versions99100```bash101# Install Python versions102uv python install 3.12103uv python install 3.11 3.12 3.13104105# Install PyPy106uv python install pypy@3.10107108# List installed and available versions109uv python list110111# Pin Python version for current directory112uv python pin 3.12113114# Upgrade to latest patch115uv python upgrade 3.12116```117118### pip Interface (drop-in replacement)119120```bash121# Create virtual environment122uv venv --python 3.12123124# Install packages125uv pip install flask requests126127# Compile requirements (like pip-compile)128uv pip compile requirements.in -o requirements.txt129130# Sync environment to match requirements131uv pip sync requirements.txt132133# Uninstall packages134uv pip uninstall flask135```136137### Common Flags138139| Flag | Description |140|---|---|141| `--python VERSION` | Use specific Python version (e.g., `3.12`, `pypy@3.10`) |142| `--with PACKAGE` | Include additional packages (run/tool contexts) |143| `--no-project` | Skip project context, run standalone |144| `--system` | Install into system Python (CI/containers) |145| `--exclude-newer DATE` | Limit to distributions released before date |146147## Gotchas148149- **`uvx` vs `uv run` for tools** — `uvx` runs in an isolated environment. Use `uv run` when the tool needs access to your project (e.g., `pytest`, `mypy`).150- **Package name vs command name** — When they differ, use `--from`: `uvx --from httpie http`.151- **Inline script metadata ignores project deps** — Scripts with `# /// script` blocks run independently of the surrounding project. No need for `--no-project`.152- **Automatic Python downloads** — uv downloads Python on-demand by default. Disable with `UV_PYTHON_DOWNLOADS=never` or `--no-managed-python`.153- **`.venv` naming** — uv creates `.venv` by default. Use `VIRTUAL_ENV=/path/to/venv` to target a different environment.154- **Lockfile format** — `uv.lock` is TOML-based and managed automatically. Do not edit it manually.155- **`--system` flag** — Required when installing into non-virtual (system) Python. Skips virtualenv discovery.156157## References158159- [01-projects](references/01-projects.md) — Project lifecycle: init, add, lock, sync, run, build160- [02-tools](references/02-tools.md) — Tool management: uvx, install, upgrade, list, uninstall161- [03-scripts](references/03-scripts.md) — Script execution, inline metadata (PEP 723), shebangs162- [04-python-versions](references/04-python-versions.md) — Python installation, discovery, pinning, upgrades163- [05-pip-interface](references/05-pip-interface.md) — pip-compatible commands: install, compile, sync, uninstall164- [06-workspaces](references/06-workspaces.md) — Multi-package workspace setup and management165- [07-resolution](references/07-resolution.md) — Resolution strategies, constraints, overrides, indexes