Installing Python with uv
Leroy · 1 Jun 2026 · 3 min read
The Problem with Python Setup
Setting up a Python project usually goes like this:
- Check if Python is installed.
- Create a virtual environment with
python -m venv venv. - Activate it. The command differs on Windows vs macOS vs Linux.
- Install packages with
pip install -r requirements.txt. - Wait. Pip resolves dependencies one by one.
It works. On large projects it is slow.
uv is a Python package and project manager written in Rust, from the team at Astral. It replaces pip, pip-tools, pipenv, poetry, and pyenv with one binary.
What is uv?
uv is a single binary that:
- Installs Python versions (
uv python install 3.12) - Creates virtual environments (
uv venv) - Installs packages from PyPI (
uv pip install) - Resolves dependencies faster than pip
- Manages projects with
pyproject.toml(uv init,uv add,uv sync)
Install it:
curl -LsSf https://astral.sh/uv/install.sh | sh
Or via a package manager:
# macOS
brew install uv
# Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
After installation, restart your shell or add ~/.cargo/bin to your PATH.
Install a Specific Python Version
This is where uv saves the most time for me. No hunting for system package managers or compiling from source:
# Install Python 3.12
uv python install 3.12
# List available versions
uv python list
# Use it
uv python pin 3.12
It downloads pre-built binaries from the Astral cache. It takes seconds. Multiple Python versions can coexist without interfering with system packages.
Creating a Virtual Environment
uv venv
This creates a .venv directory using the Python version pinned in .python-version or the latest available. It works like python -m venv .venv but is faster.
Activate it the usual way:
source .venv/bin/activate # macOS/Linux
.venv\Scripts\activate # Windows
Or use uv run to skip activation. It automatically uses the project's virtual environment:
uv run python myscript.py
Installing Packages
The pip-compatible interface:
# Install a single package
uv pip install flask
# Install from requirements.txt
uv pip install -r requirements.txt
# Install from pyproject.toml
uv sync
The first time you run uv pip install, it downloads and caches packages. Subsequent runs are faster because the resolution is cached globally.
Working with Projects
uv has a project management mode that works like Rust's cargo or Node.js's npm:
# Create a new project
uv init my-project
cd my-project
# Add dependencies
uv add flask
uv add --dev pytest
# Install everything
uv sync
# Run a command in the project's venv
uv run python app.py
This creates a pyproject.toml and uv.lock file. The lock file pins exact versions for every transitive dependency, giving you deterministic installs.
Why I Use uv
Speed
Pip resolves dependencies one at a time. uv downloads metadata in parallel and caches aggressively. On a project with 50 or more dependencies, pip takes 30 to 60 seconds. uv takes 1 to 3 seconds.
Single Binary
I do not need pyenv, pipenv, poetry, and virtualenv installed separately. One binary replaces all of them. It is around 10MB.
Python Version Management
I no longer rely on my system package manager's Python version. uv downloads any Python version I need in seconds. This is useful when I work across multiple projects that require different Python versions.
Deterministic Builds
The uv.lock file, like package-lock.json or Cargo.lock, ensures everyone on the team gets the same dependency tree. No more "it works on my machine."
Drop-in Compatible
If you already have a project using requirements.txt and pip, uv works without changes. Run uv pip install instead of pip install. Everything else stays the same.
The Downsides
- uv is relatively new. Its first stable release was in 2024. Some edge cases in dependency resolution are still being worked out.
- There are no ARM Windows builds yet. If you are on ARM Windows, you need the x86 emulation layer.
- uv works only with PyPI-compatible registries. Private repositories using other formats may not work.
Summary
uv is my default Python tool now. It replaces pyenv, pip, pipenv, and poetry with a single binary.