uv: Fast Python package and project manager

TenithTenith
3 min read

uv is a super-fast Python tool that replaces all your Python management tools in one simple package. No more juggling pip, virtualenv, poetry, and pyenv - just use uv.

What uv Replaces

  • pip → Package installation

  • virtualenv → Environment management

  • poetry → Project management

  • pyenv → Python version management

  • pipx → Tool installation

Installation

Install uv:

# Mac/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

# Keep it updated
uv self update

Main Features

1. Project Management

uv init myproject         # Create new project
uv add pandas            # Add package to project
uv remove pandas         # Remove package
uv sync                  # Update project environment
uv run python app.py     # Run code in project

2. Environment Management

uv venv                  # Create environment

Activate environment:

  • macOS/Linux: source .venv/bin/activate

  • Windows: .venv\Scripts\activate

2. Quick Tools (No Installation)

uvx black myfile.py      # Format code once
uvx pytest              # Run tests once
uvx jupyter notebook     # Start Jupyter once

3. Install Tools Permanently

uv tool install black    # Install formatter
uv tool install pytest   # Install test runner
uv tool list             # See installed tools

4. Python Version Control

uv python install 3.12   # Install Python 3.12
uv python list           # See all Python versions
uv python pin 3.11       # Use Python 3.11 for this folder

5. Regular Package Commands

uv pip install requests  # Install package (like pip)
uv pip list              # List packages
uv pip uninstall requests # Remove package

Complete Example: Building a Weather App

Let's build a weather app from start to finish:

Step 1: Create Project

uv init weather-app
cd weather-app

Step 2: Add Dependencies

uv add requests typer rich

Step 3: Write the App (main.py)

import requests
import typer
from rich.console import Console
from rich.table import Table

console = Console()

def get_weather(city: str):
    """Get weather for a city"""
    # Using OpenWeatherMap API (you'd need a real API key)
    url = f"http://api.openweathermap.org/data/2.5/weather"

    # Mock data for demo
    weather_data = {
        "name": city.title(),
        "main": {"temp": 22, "humidity": 65},
        "weather": [{"description": "sunny"}]
    }

    table = Table(title=f"Weather in {weather_data['name']}")
    table.add_column("Property", style="cyan")
    table.add_column("Value", style="green")

    table.add_row("Temperature", f"{weather_data['main']['temp']}°C")
    table.add_row("Humidity", f"{weather_data['main']['humidity']}%")
    table.add_row("Description", weather_data['weather'][0]['description'])

    console.print(table)

if __name__ == "__main__":
    typer.run(get_weather)

Step 4: Run the App

uv run python main.py "New York"

Step 5: Format Code

uvx black main.py

Step 6: Test Installation

uvx pytest --version  # Check if we can run tests

What You Get:

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃     Weather in New York   ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Property    │ Value       │
├─────────────┼─────────────┤
│ Temperature │ 22°C        │
│ Humidity    │ 65%         │
│ Description │ sunny       │
└─────────────┴─────────────┘

Why uv is Better

Speed: 10-100x faster than pip Simple: One tool instead of five Smart: Automatic dependency resolution Clean: No leftover files or broken environments

Quick Reference

TaskOld Wayuv WayNew projectmkdir + virtualenv + pipuv initAdd packagepip install + requirements.txtuv addRun tool oncepip install + tool + pip uninstalluvx toolInstall PythonDownload + install manuallyuv python installRun in envsource venv/bin/activate + pythonuv run python

Start using uv today and simplify your Python workflow dramatically.

0
Subscribe to my newsletter

Read articles from Tenith directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tenith
Tenith