Blazing-Fast Dependency Management with uv
Use uv from Astral as a drop-in replacement for pip and virtualenv with 10-100x faster installs and built-in project management.
Prerequisites
- -Python 3.8+ installed
Steps
Install uv
Install the uv package manager globally. It is a single static binary with no Python dependency required for installation.
On Windows, use: powershell -c "irm https://astral.sh/uv/install.ps1 | iex" instead.
Create a new project
Scaffolds a new Python project with pyproject.toml, a src layout, and a ready-to-use .venv. No manual environment creation needed.
Add dependencies
Adds packages to pyproject.toml and installs them into the managed virtual environment. The lock file (uv.lock) is updated automatically.
Use 'uv add --dev pytest ruff' to add development-only dependencies.
Add development dependencies
Adds packages to the dev dependency group. These are installed during development but excluded from production builds.
Run a script in the project environment
Runs the script using the project's managed virtual environment. You do not need to manually activate the venv.
uv run automatically syncs dependencies before executing, so you never have a stale environment.
Sync and lock dependencies
Regenerate the lock file from pyproject.toml and sync the virtual environment to match. Use this after manually editing pyproject.toml.
Always commit uv.lock to version control. It ensures every team member and CI gets the exact same dependency versions.
Full Script
FAQ
Discussion
Loading comments...