Unified Python Management with uv: A High-Performance Tutorial
Overview
pip, poetry, pyenv, and virtualenv. The primary advantage is speed;

Prerequisites
To follow this guide, you should have a basic understanding of the Python ecosystem, including how to use the terminal and the purpose of a pyproject.toml file. While no specific version of Python is required to start—since
Key Libraries & Tools
- uv: An extremely fast Python package and project manager.
- Ruff: An extremely fast Python linter and formatter, also byAstral.
- Homebrew: A macOS package manager used for easy installation.
- Cargo: The Rust package manager, used if buildinguvfrom source.
Code Walkthrough
Installation
On macOS, install via
brew install uv
Alternatively, use a standalone script for any OS:
curl -LsSf https://astral.sh/uv/install.sh | sh
Project Initialization
Create a new project structure with a standard pyproject.toml and a managed virtual environment:
uv init my-project
cd my-project
This command generates a boilerplate .python-version file, and a basic hello.py script.
Managing Dependencies
Add and remove packages seamlessly.
uv add pandas fast-api
uv remove sql-alchemy
Executing Code
Run scripts directly within the context of your managed environment without manually activating it:
uv run hello.py
Syntax Notes
npm. The uvx command (shorthand for uv tool run) allows for one-off execution of CLI tools like
Practical Examples
In monorepo environments,
Tips & Gotchas
- Shell Completion: Enable tab-completion for faster terminal navigation by running
uv generate-shell-completion zshand adding it to your config. - Build Systems: Currently, uvrelies on backends like
hatchlingfor building packages. It does not yet include a built-in Rust-based build backend, though this is actively being developed. - Python Versions: Use
uv python install 3.13to manage runtimes without needingpyenv.