uv: Python Package and Project Manager
uv is a high-performance Python package and project manager that provides a unified interface for installing Python versions, managing dependencies, creating virtual environments, running scripts, formatting code, building packages, and publishing to package indexes.
Note
This is a reference guide for uv. For a comprehensive overview, see uv: A Complete Guide. For a hands-on tutorial, see Create your first Python project.
When to use uv
Use uv when you want a single tool for managing Python versions, virtual environments, dependencies, and package publishing instead of combining pip, pyenv, pipx, and others. It is a strong default for new Python projects and for developers who value fast installs and reproducible lockfiles. If your project relies on non-Python scientific libraries, conda may be a better fit; for a comparison with pip, see What’s the difference between pip and uv?.
Why uv?
Traditional Python development involves juggling multiple tools (e.g. pip, pip-tools, pipx, poetry, pyenv, virtualenv), each with different interfaces and behaviors. uv unifies these workflows while delivering 10-100x performance improvements over existing solutions.
- Speed: 10-100x faster than traditional Python tools
- Simplicity: One tool for all Python packaging needs
- Standards: Full compatibility with modern Python packaging standards
- Reliability: Reproducible builds with universal lockfiles
Installation
Quick Install
curl -LsSf https://astral.sh/uv/install.sh | shSee How to install uv for alternative methods and troubleshooting.
Command Categories
Project Management
Projects use pyproject.toml for configuration and uv.lock for dependency locking.
# Initialize new project
uv init my-project
# Add dependencies
uv add requests
uv add --dev pytest # development dependency
# Remove a dependency
uv remove requests
# Read or update the project version
uv version
uv version 1.2.0
uv version --bump minor
# Resolve and lock dependencies
uv lock
# Install project and dependencies
uv sync
# Run commands in project environment
uv run python main.py
uv run pytest
# Display the dependency tree
uv tree
# Export lockfile to requirements.txt format
uv export --format requirements-txt
# Build distributions
uv build
# Publish to PyPI
uv publishScript Execution
Run standalone Python scripts with automatic dependency management.
# Run script with inline dependencies
uv run script.py
# Run with additional dependencies
uv run --with requests script.py
# Add dependencies to script metadata
uv add --script script.py requestsInline Script Dependencies
uv allows you to specify dependencies for a script in the script itself, using the dependencies key.
Run uv add --script script.py requests rich to add the requests and rich dependencies to your script.
# /// script
# dependencies = ["requests", "rich"]
# requires-python = ">=3.8"
# ///
import requests
from rich import printNote
Inline script dependencies are a PEP 723 compliant way to specify dependencies for a script.
Formatting
uv includes a built-in code formatting command powered by Ruff’s formatter:
# Format all Python files in the project
uv format
# Check formatting without making changes
uv format --check
# Show what would change
uv format --diffFormatting configuration is read from the project’s pyproject.toml under [tool.ruff.format], the same settings Ruff uses directly.
Tool Management
Install and run Python-based CLI tools in isolated environments.
# Run tool temporarily
uvx ruff .
# Install tool globally
uv tool install ruff
# Upgrade tools
uv tool upgrade ruff
uv tool upgrade --allPython Version Management
Install and manage Python interpreters without relying on system packages or pyenv.
# List available and installed Python versions
uv python list
# Install a specific Python version
uv python install 3.12
# Pin the project to a Python version
uv python pin 3.12
# Find where a Python version is installed
uv python find 3.12See How to install Python with uv and How to change the Python version of a uv project for more detail.
pip-Compatible Interface
uv provides a drop-in replacement for pip/pip-tools workflows with enhanced performance.
# Create virtual environment
uv venv
# Install packages
uv pip install requests
uv pip install -r requirements.txt
uv pip install -e . # editable install
# Generate lockfiles
uv pip compile requirements.in
uv pip compile --universal requirements.in # cross-platform
# Sync environment with lockfile
uv pip sync requirements.txtLearn More
Handbook guides
- Create your first Python project
- Setting up testing with pytest and uv
- Run your first Python script with uv
- How to install uv
- How to migrate from requirements.txt to pyproject.toml with uv
- How to change the Python version of a uv project
- uv: A Complete Guide
- What’s the difference between pip and uv?
Official documentation
Also Mentioned In
- uv: A Complete Guide to Python's Fastest Package Manager
- ty: A Complete Guide to Python's Fastest Type Checker
- Ruff: A Complete Guide to Python's Fastest Linter and Formatter
- Getting Started with Python Using Claude Code
- LiteLLM Got Owned, and Your Dependencies Might Be Next
- OpenAI to Acquire Astral
- Charlie Marsh on uv, Coding Agents, and the Changing Open Source Contract
- Pydantic Monty: A Secure Python Interpreter for AI Agents
- FOSDEM Talk: Modern Python Monorepo with uv, Workspaces, and prek
- uvx.sh: Install Python tools without uv or Python
- ty is Built with AI
- How uv Achieved Its Performance
- Teaching LLMs Python Best Practices
- Claude Code Hooks for uv Projects
- uv format: Code Formatting Comes to uv (experimentally!)
- Google Sunsets Pytype: The End of an Era for Python Type Checking
- How Python's RFC Process Paved the Way for uv, Ruff, and Ty
- Use Interceptors to teach Claude Code to use uv
- uvhow: Get uv upgrade instructions for your uv install
- uv 0.8 Release: Automatic Python Installation to PATH
- Hynek Schlawack's uv Workflow Guide
- The uv build backend is now stable
- Managing Python Versions In Your uv Projects
- Pyrefly: Meta's New Type Checker for Python
- Why uv makes Make less essential for Python projects
- The Python Tooling Revolution
- Simple, Modern Python
- Production Experiences with uv
- Effective Python Developer Tooling in December 2024
- Quick start guide for Python development on a Mac
- Introduction to Rye
- Conda: Python Package and Environment Manager
- Create your first Python project
- Flit: Python Package Build and Publish Tool
- Hatch: Python Project Manager
- How do mypy, pyright, and ty compare?
- How do pyenv and uv compare for Python interpreter management?
- How do uv and Poetry compare?
- How Python tools adopt uv under the hood
- How to add dynamic versioning to uv projects
- How to add Python to your system path with uv
- How to change the python version of a uv project
- How to configure Claude Code to use uv
- How to configure Cursor for a uv project
- How to configure Cursor rules to use uv
- How to configure mypy strict mode
- How to configure VS Code for a uv project
- How to Fix Common pytest Errors with uv
- How to Fix ModuleNotFoundError: No module named 'numpy' During pip Install
- How to fix Python version incompatibility errors in uv
- How to gradually adopt type checking in an existing Python project
- How to install Python CLI tools without Python
- How to Install PyTorch with uv
- How to Install RAPIDS with uv
- How to install the Astral plugins for Claude Code
- How to install uv
- How to install uv on Linux
- How to install uv on macOS
- How to install uv on Windows
- How to migrate from mypy to ty
- How to migrate from Poetry to uv
- How to migrate from requirements.txt to pyproject.toml with uv
- How to Protect Against Python Supply Chain Attacks with uv
- How to Publish to PyPI with Trusted Publishing
- How to put your Python project on GitHub
- How to require a virtualenv when installing packages with pip?
- How to Run a Jupyter Notebook with uv
- How to run tests in parallel with pytest-xdist
- How to Run Tests Using uv
- How to run the IPython shell in your uv project
- How to Scan Python Dependencies for Vulnerabilities
- How to set up a Python monorepo with uv workspaces
- How to set up pre-commit hooks for a Python project
- How to set up prek hooks for a Python project
- How to Test Against Multiple Python Versions Using uv
- How to try the ty type checker
- How to upgrade uv
- How to Use `--exclude-newer` for Reproducible Python Environments
- How to use a uv lockfile for reproducible Python environments
- How to use pip in a uv virtual environment
- How to Use Poe the Poet as a Task Runner with uv
- How to use private package indexes with uv
- How to use the pydevtools CLAUDE.md template for Python projects
- How to use ty in CI
- How to use uv in a Dockerfile
- How to use uv to speed up Hatch
- How to use uv to speed up PDM
- How to use uv to speed up tox
- How to Verify Dependencies with Hashes in uv
- How to write self-contained Python scripts using PEP 723 inline metadata
- Modern Python Project Setup Guide for AI Assistants
- PDM: Python Package and Dependency Manager
- pip: Python Package Installer
- pip-tools: Python Dependency Pinning Tools
- pipx: Install Python CLI Tools in Isolation
- Pixi: Multi-Language Package and Workflow Manager
- Poetry: Python Packaging and Dependency Manager
- prek: Fast Pre-commit Hook Runner for Python
- Publishing Your First Python Package to PyPI
- pyproject.toml: Python Project Configuration File
- requirements.txt: Python Dependency File Format
- Ruff: Python Linter and Formatter
- Run your first Python script
- sdist: Python Source Distribution Format
- Setting up GitHub Actions with uv
- Setting up testing with pytest and uv
- setuptools: Python Package Build Backend
- Should I use Homebrew to install Python?
- tox-uv: uv backend for tox
- ty: Python Type Checker by Astral
- Understanding dependency groups in uv
- uv vs pixi vs conda for Scientific Python
- venv: Python Built-in Virtual Environment Module
- virtualenv: Python Virtual Environment Tool
- What is a .python-version file?
- What is a build backend?
- What is a lockfile?
- What is a Python package?
- What is PEP 503?
- What is PEP 609?
- What is PEP 723?
- What is PEP 751?
- What's the difference between pip and uv?
- Wheel: Python Binary Distribution Format
- When should I choose pixi over uv?
- When to Use `uv run` vs `uvx`
- Which Python package manager should I use?
- Why are there so many Python packaging tools?
- Why did uv originally use Hatch as a build backend?
- Why Installing GPU Python Packages Is So Complicated
- Why should I avoid using the system Python?
- Why should I choose Conda?
- Why Should I Choose pyproject.toml over requirements.txt for managing dependencies?
- Why should I use a virtual environment?
- Why use native uv commands instead of uv pip
- Why Use Trusted Publishing for PyPI?
- Why You Should Try uv if You Use Python
Get Python tooling updates
Subscribe to the newsletter