uv is an extremely fast Python package installer and resolver, written in Rust. It's designed as a drop-in replacement for pip and pip-tools.
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# With brew
brew install uv
# With pip
pip install uv# Create a virtual environment
uv venv
# Install packages
uv pip install requests
uv pip install -r requirements.txt
# Compile requirements
uv pip compile requirements.in -o requirements.txt
# Show installed packages
uv pip list
# Uninstall packages
uv pip uninstall requestsuv pip sync synchronizes the environment to match a requirements file exactly. It will install missing packages and uninstall any packages not listed in the requirements file.
# Sync environment with requirements.txt
uv pip sync requirements.txt
# Sync with multiple requirement files
uv pip sync requirements.txt dev-requirements.txt
# Dry run to see what would change
uv pip sync requirements.txt --dry-run
# Sync with a specific Python version
uv pip sync requirements.txt --python 3.11# 1. Compile dependencies from requirements.in
uv pip compile requirements.in -o requirements.txt
# 2. Sync environment to match compiled requirements
uv pip sync requirements.txt
# This ensures your environment exactly matches the locked dependenciesuvx runs Python applications in isolated temporary environments (similar to npx for Node.js).
# Run a Python tool without installing it
uvx ruff check .
uvx black --check .
uvx pytest
# Run a specific version
uvx ruff@0.1.0 check .
# Run with additional packages
uvx --with pandas --with numpy python script.py
# Run from a specific Python version
uvx --python 3.11 black --check .
# Run a script from a URL
uvx https://example.com/script.py# Code formatting
uvx black .
uvx isort .
# Linting
uvx ruff check .
uvx flake8 .
uvx pylint mypackage/
# Type checking
uvx mypy .
# Testing
uvx pytest
uvx coverage run -m pytest
# Project scaffolding
uvx cookiecutter gh:user/template
# HTTP requests
uvx httpie https://api.example.com
# Package publishing
uvx twine upload dist/*# Initialize a new project
uv init myproject
cd myproject
# Add a dependency
uv add requests
# Add a dev dependency
uv add --dev pytest
# Remove a dependency
uv remove requests
# Run a command in the project environment
uv run python script.py
uv run pytest
# Sync project dependencies
uv syncuv is significantly faster than pip:
- 10-100x faster for most operations
- Parallel downloads
- Better dependency resolution
- Cached package installations
- Use
uv pip syncfor reproducible environments in CI/CD - Use
uvxfor one-off tool executions without polluting your environment - Combine with
requirements.infiles for dependency management - uv caches packages globally for faster reinstalls
- uv respects
PIP_INDEX_URLand other pip environment variables