uv β Fast Python Package Manager#
What it is#
uv is a Python package installer and resolver written in Rust by Astral (the same team that makes ruff). It is a drop-in replacement for pip, pip-tools, and virtualenv that runs 10β100Γ faster. It also supports project-level workflows (uv init, uv add, uv run) as an alternative to poetry.
Install#
# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# Or via pip (if you already have Python)
pip install uv
Quick example β install packages#
uv pip install requests pandas
Output:
Resolved 7 packages in 312ms
Installed 7 packages in 143ms
+ certifi==2024.2.2
+ charset-normalizer==3.3.2
+ idna==3.7
+ numpy==2.0.0
+ pandas==2.2.2
+ python-dateutil==2.9.0
+ requests==2.32.3
When / why to use it#
- Replacement for pip: faster resolution, better error messages, compatible commands.
- Replacement for virtualenv + pip-tools:
uv venv+uv pip compilereplace those two tools. - Replacement for poetry (for many use cases):
uv init+uv add+uv rungive a poetry-like workflow.
[!TIP] If youβre starting a new project from scratch,
uvis the recommended tool in 2026. For existing poetry projects, migration is low-effort but optional.
Common pitfalls#
[!WARNING] uv is not pip β
uv pip installinstalls into the active virtual environment, not the system Python. If no venv is active, uv installs into an auto-created project venv. Runuv venvfirst to be explicit.
[!WARNING]
uv runis notpythonβuv run script.pyuses the projectβs venv and can install dependencies on the fly. It is not a direct replacement forpython script.pyin all contexts.
Virtual environments#
uv venv # creates .venv in current directory
uv venv --python 3.12 # specify Python version
source .venv/bin/activate # activate (Linux/macOS)
.venv\Scripts\activate # activate (Windows)
Output:
Using CPython 3.12.3
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
Richer example β project workflow#
# Initialize a new project
uv init myapp
cd myapp
# Add dependencies
uv add fastapi "uvicorn[standard]"
uv add --dev pytest ruff mypy
# Run a script
uv run uvicorn main:app --reload
# Sync dependencies from uv.lock
uv sync
# Show what's installed
uv pip list
Output:
Initialized project `myapp` at `/home/user/myapp`
Resolved 18 packages in 1.2s
Installed 18 packages in 380ms
+ annotated-types==0.7.0
+ anyio==4.4.0
+ fastapi==0.111.1
+ uvicorn==0.30.1
+ ...
INFO: Started server process [12345]
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
Drop-in pip commands#
uv pip install <pkg> # install
uv pip install -r requirements.txt # from file
uv pip install -e . # editable install
uv pip uninstall <pkg>
uv pip list
uv pip freeze > requirements.txt
uv pip compile requirements.in # pin transitive deps β requirements.txt
Install Python versions#
uv can download and manage Python interpreters:
uv python install 3.12
uv python install 3.13
uv python list # show available versions
Output:
Installed Python 3.12.3 in 8.4s
+ cpython-3.12.3-linux-x86_64-gnu
uv vs pip vs poetry#
| Feature | pip | poetry | uv |
|---|---|---|---|
| Install speed | Slow | Slow | Fast (Rust) |
| Lockfile | β (use pip-tools) | β | β
(uv.lock) |
| Project management | β | β | β |
| Python version mgmt | β | β | β |
pyproject.toml support | Partial | β | β |
| Drop-in for pip | β | β | β |