Master the uv package manager for fast Python dependency management, virtual environments, and modern Python project workflows. Use when setting up Python projects, managing dependencies, or optimizing Python development workflows with uv.
Use the skills CLI to install this skill with one command. Auto-detects all installed AI assistants.
Method 1 - skills CLI
npx skills i wshobson/agents/plugins/python-development/skills/uv-package-managerMethod 2 - openskills (supports sync & update)
npx openskills install wshobson/agentsAuto-detects Claude Code, Cursor, Codex CLI, Gemini CLI, and more. One install, works everywhere.
Installation Path
Download and extract to one of the following locations:
No setup needed. Let our cloud agents run this skill for you.
Select Provider
Select Model
Best for coding tasks
No setup required
Comprehensive guide to using uv, an extremely fast Python package installer and resolver written in Rust, for modern Python project management and dependency workflows.
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell)
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# Using pip (if you already have Python)
pip install uv
# Using Homebrew (macOS)
brew install uv
# Using cargo (if you have Rust)
cargo install --git https://github.com/astral-sh/uv uvuv --version
# uv 0.x.x# Create new project with virtual environment
uv init my-project
cd my-project
# Or create in current directory
uv init .
# Initialize creates:
# - .python-version (Python version)
# - pyproject.toml (project config)
# - README.md
# - .gitignore# Install packages (creates venv if needed)
uv add requests pandas
# Install dev dependencies
uv add --dev pytest black ruff
# Install from requirements.txt
uv pip install -r requirements.txt
# Install from pyproject.toml
uv sync# Create virtual environment with uv
uv venv
# Create with specific Python version
uv venv --python 3.12
# Create with custom name
uv venv my-env
# Create with system site packages
uv venv --system-site-packages
# Specify location
uv venv /path/to/venv# Linux/macOS
source .venv/bin/activate
# Windows (Command Prompt)
.venv\Scripts\activate.bat
# Windows (PowerShell)
.venv\Scripts\Activate.ps1
# Or use uv run (no activation needed)
uv run python script.py
uv run pytest# Run Python script (auto-activates venv)
uv run python app.py
# Run installed CLI tool
uv run black .
uv run pytest
# Run with specific Python version
uv run --python 3.11 python script.py
# Pass arguments
uv run python script.py --arg value# Add package (adds to pyproject.toml)
uv add requests
# Add with version constraint
uv add "django>=4.0,<5.0"
# Add multiple packages
uv add numpy pandas matplotlib
# Add dev dependency
uv add --dev pytest pytest-cov
# Add optional dependency group
uv add --optional docs sphinx
# Remove package
uv remove requests
# Remove dev dependency
uv remove --dev pytest
# Remove multiple packages
uv remove numpy pandas matplotlib# Upgrade specific package
uv add --upgrade requests
# Upgrade all packages
uv sync --upgrade
# Upgrade package to latest
uv add --upgrade requests
# Show what would be upgraded
uv tree --outdated# Generate uv.lock file
uv lock
# Update lock file
uv lock --upgrade
# Lock without installing
uv lock --no-install
# Lock specific package
uv lock --upgrade-package requests# Install Python version
uv python install 3.12
# Install multiple versions
uv python install 3.11 3.12 3.13
# Install latest version
uv python install
# List installed versions
uv python list
# Find available versions
uv python list --all-versions# Set Python version for project
uv python pin 3.12
# This creates/updates .python-version file
# Use specific Python version for command
uv --python 3.11 run python script.py
# Create venv with specific version
uv venv --python 3.12[project]
name = "my-project"
version = "0.1.0"
description = "My awesome project"
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
"requests>=2.31.0",
"pydantic>=2.0.0",
"click>=8.1.0",
]
[project.optional-dependencies
# Migrate from requirements.txt
uv add -r requirements.txt
# Migrate from poetry
# Already have pyproject.toml, just use:
uv sync
# Export to requirements.txt
uv pip freeze > requirements.txt
# Export with hashes
uv pip freeze --require-hashes > requirements.txt# Project structure
# monorepo/
# packages/
# package-a/
# pyproject.toml
# package-b/
# pyproject.toml
# pyproject.toml (root)
# Root pyproject.toml
[tool.uv.workspace]
members = ["packages/*"]
# Install all workspace packages
uv sync
# Add workspace dependency
uv add --path ./packages/package-a# .github/workflows/test.yml
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
# Dockerfile
FROM python:3.12-slim
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Set working directory
WORKDIR /app
# Copy dependency files
COPY pyproject.toml uv.lock ./
# Install dependencies
RUN uv sync --frozen --no-dev
# Copy application code
COPY . .
# Run application
CMD ["uv", "run", Optimized multi-stage build:
# Multi-stage Dockerfile
FROM python:3.12-slim AS builder
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
# Install dependencies to venv
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --no-editable
# Runtime stage
FROM python:3.12-slim
WORKDIR /app
# Copy venv from builder
COPY --from=builder /app/.venv .venv
# Create lockfile (uv.lock)
uv lock
# Install from lockfile (exact versions)
uv sync --frozen
# Update lockfile without installing
uv lock --no-install
# Upgrade specific package in lock
uv lock --upgrade-package requests
# Check if lockfile is up to date
uv lock --check
# Export lockfile to requirements.txt
uv export --format requirements-txt
# UV automatically uses global cache at:
# Linux: ~/.cache/uv
# macOS: ~/Library/Caches/uv
# Windows: %LOCALAPPDATA%\uv\cache
# Clear cache
uv cache clean
# Check cache size
uv cache dir# UV installs packages in parallel by default
# Control parallelism
uv pip install --jobs 4 package1 package2
# No parallel (sequential)
uv pip install --jobs 1 package# Install from cache only (no network)
uv pip install --offline package
# Sync from lockfile offline
uv sync --frozen --offline# pip
python -m venv .venv
source .venv/bin/activate
pip install requests pandas numpy
# ~30 seconds
# uv
uv venv
uv add requests pandas numpy
# ~2 seconds (10-15x faster)# poetry
poetry init
poetry add requests pandas
poetry install
# ~20 seconds
# uv
uv init
uv add requests pandas
uv sync
# ~3 seconds (6-7x faster)# pip-tools
pip-compile requirements.in
pip-sync requirements.txt
# ~15 seconds
# uv
uv lock
uv sync --frozen
# ~2 seconds (7-8x faster)# Complete workflow
uv init my-project
cd my-project
# Set Python version
uv python pin 3.12
# Add dependencies
uv add fastapi uvicorn pydantic
# Add dev dependencies
uv add --dev pytest black ruff mypy
# Create structure
mkdir -p src/my_project tests
# Clone repository
git clone https://github.com/user/project.git
cd project
# Install dependencies (creates venv automatically)
uv sync
# Install with dev dependencies
uv sync --all-extras
# Update dependencies
uv lock --upgrade
# Run application
uv run python app.py
# Run tests
uv run pytest
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: uv-lock
name: uv lock
entry: uv lock
language: system
pass_filenames: false
- id: ruff
name
// .vscode/settings.json
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.terminal.activateEnvironment": true,
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": ["-v"],
"python.linting.enabled": true,
"python.formatting.provider": "black",
"[python]": {
"editor.defaultFormatter"
# Issue: uv not found
# Solution: Add to PATH or reinstall
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
# Issue: Wrong Python version
# Solution: Pin version explicitly
uv python pin 3.12
uv venv --python 3.12
# Issue: Dependency conflict
# Solution: Check resolution
uv lock --verbose
# Issue: Cache issues
# Solution: Clear cache
uv cache clean
# Use frozen installs in CI
uv sync --frozen
# Use offline mode when possible
uv sync --offline
# Parallel operations (automatic)
# uv does this by default
# Reuse cache across environments
# uv shares cache globally
# Use lockfiles to skip resolution
uv sync --frozen # skips resolution# Before
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# After
uv venv
uv pip install -r requirements.txt
# Or better:
uv init
uv add -r requirements.txt# Before
poetry install
poetry add requests
# After
uv sync
uv add requests
# Keep existing pyproject.toml
# uv reads [project] and [tool.poetry] sections# Before
pip-compile requirements.in
pip-sync requirements.txt
# After
uv lock
uv sync --frozen# Project management
uv init [PATH] # Initialize project
uv add PACKAGE # Add dependency
uv remove PACKAGE # Remove dependency
uv sync # Install dependencies
uv lock # Create/update lockfile
# Virtual environments
uv venv
uv init