In this guide, we will walk through installing uv on macOS and Windows, initializing your first clean Python project, and mastering modern local development workflows.
Why Choose uv?
Traditional Python package management suffers from sequential downloads, slow wheel compilation, and fragile dependency solvers. uv solves this by introducing:
- Blazing Speed: Written in Rust, it utilizes aggressive global caching, parallel downloads, and advanced caching algorithms to install dependencies in milliseconds.
- All-in-One Engine: It manages Python versions, virtual environments, project configurations, tool executing (
pipx-equivalent), and dependencies. - Zero-Configuration Versioning:
uvautomatically downloads and sets up the correct Python version (e.g., Python 3.12) required for your project without needing external tools likepyenv. - Standardized Configuration: Uses standard
pyproject.tomlfiles, ensuring compatibility across modern packaging tools.
1. Installing uv
uv is distributed as a single standalone binary, meaning it doesn't need Python to be pre-installed on your system to work.
Installation on macOS and Linux
You can install uv via a standalone shell script:
curl -LsSf https://astral.sh/uv/install.sh | sh
Alternatively, if you use Homebrew:
brew install astral-sh/uv/uv
Installation on Windows
Open PowerShell and run the following execution command:
irm https://astral.sh/uv/install.ps1 | iex
To verify that uv is installed correctly, run:
uv --version
2. Managing Python Runtimes Automatically
With uv, you no longer need to manually install Python from python.org or manage multiple versions via your system package manager. uv handles Python runtimes dynamically.
- List available Python versions:
uv python list - Install a specific Python version globally:
uv python install 3.12
If a project requires a specific Python version (e.g., requires-python = ">=3.11"), uv will fetch and run it automatically behind the scenes.
3. Creating Your First Python Project
Let's initialize a brand new project and configure its environment using uv's clean project structure.
Step 1: Initialize the Project
Create a new directory and initialize a basic structure:
mkdir my-python-project
cd my-python-project
uv init
This commands creates:
pyproject.toml: The standard project metadata and dependency configuration.hello.py: A boilerplate hello world Python script..python-version: A file pinning the Python version to use for this directory.
Step 2: Adding Dependencies
To add packages (such as requests or fastapi) to your project, use uv add. uv will resolve the dependencies, write them to your pyproject.toml, create an isolated virtual environment at .venv/, and lock the versions in uv.lock:
uv add requests
If you open pyproject.toml, you will see your dependencies configured cleanly:
[project]
name = "my-python-project"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"requests>=2.31.0",
]
Step 3: Syncing the Environment
If you clone an existing project containing a pyproject.toml or uv.lock, you can recreate the exact virtual environment locally with one command:
uv sync
4. Modern Python Workflows
One of uv's biggest advantages is how it streamlines running code.
Running Scripts Without Manual Virtual Environment Activation
Traditionally, you have to run source .venv/bin/activate before executing your Python scripts. With uv, you run:
uv run hello.py
uv run automatically executes your script inside the context of the project's virtual environment, guaranteeing all installed dependencies are in scope.
Running CLI Tools with uvx
If you need to execute a Python CLI tool (like ruff for formatting or black for linting) but don't want to install it permanently in your project, use uvx (the npx equivalent for Python):
uvx ruff format hello.py
uvx downloads the tool into a ephemeral environment, formats the file, and discards the overhead—keeping your global environment completely clean.
Conclusion
By adopting uv, you eliminate the complexity of virtual environments, version conflicts, and slow installers. It sets a clean, modern foundation for your local machine, preparing your environment for complex workflows like full-stack development, automation scripting, and local AI modeling.