Unified Python Management with uv: A High-Performance Tutorial

ArjanCodes////3 min read

Overview

uv represents a paradigm shift in Python tooling. Developed by Astral in Rust, it acts as a high-performance replacement for pip, poetry, pyenv, and virtualenv. The primary advantage is speed; uv resolves and installs packages significantly faster than legacy tools while providing a unified interface for managing Python versions and virtual environments.

Unified Python Management with uv: A High-Performance Tutorial
This Tool Replaces pip, Poetry, pyenv, and More (It’s Fast)

Prerequisites

To follow this guide, you should have a basic understanding of the Python ecosystem, including how to use the terminal and the purpose of a pyproject.toml file. While no specific version of Python is required to start—since uv can install Python for you—having a shell environment like Zsh or Bash is necessary.

Key Libraries & Tools

  • uv: An extremely fast Python package and project manager.
  • Ruff: An extremely fast Python linter and formatter, also by Astral.
  • Homebrew: A macOS package manager used for easy installation.
  • Cargo: The Rust package manager, used if building uv from source.

Code Walkthrough

Installation

On macOS, install via Homebrew:

brew install uv

Alternatively, use a standalone script for any OS:

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

Project Initialization

Create a new project structure with a standard pyproject.toml and a managed virtual environment:

uv init my-project
cd my-project

This command generates a boilerplate Git setup, a .python-version file, and a basic hello.py script.

Managing Dependencies

Add and remove packages seamlessly. uv automatically updates your requirements and syncs the environment:

uv add pandas fast-api
uv remove sql-alchemy

Executing Code

Run scripts directly within the context of your managed environment without manually activating it:

uv run hello.py

Syntax Notes

uv uses a command structure reminiscent of Cargo or npm. The uvx command (shorthand for uv tool run) allows for one-off execution of CLI tools like Ruff without permanently adding them to your project dependencies.

Practical Examples

In monorepo environments, uv supports Workspaces. This allows multiple projects to share a single lockfile and virtual environment, reducing disk usage and ensuring version consistency across different microservices or internal libraries.

Tips & Gotchas

  • Shell Completion: Enable tab-completion for faster terminal navigation by running uv generate-shell-completion zsh and adding it to your config.
  • Build Systems: Currently, uv relies on backends like hatchling for building packages. It does not yet include a built-in Rust-based build backend, though this is actively being developed.
  • Python Versions: Use uv python install 3.13 to manage runtimes without needing pyenv.
Topic DensityMention share of the most discussed topics · 23 mentions across 11 distinct topics
uv
39%· products
Astral
9%· companies
Cargo
9%· products
Homebrew
9%· products
Ruff
9%· products
Other topics
26%
End of Article
Source video
Unified Python Management with uv: A High-Performance Tutorial

This Tool Replaces pip, Poetry, pyenv, and More (It’s Fast)

Watch

ArjanCodes // 17:35

On this channel, I post videos about programming and software design to help you take your coding skills to the next level. I'm an entrepreneur and a university lecturer in computer science, with more than 20 years of experience in software development and design. If you're a software developer and you want to improve your development skills, and learn more about programming in general, make sure to subscribe for helpful videos. I post a video here every Friday. If you have any suggestion for a topic you'd like me to cover, just leave a comment on any of my videos and I'll take it under consideration. Thanks for watching!

What they talk about
AI and Agentic Coding News
Who and what they mention most
Python
27.3%3
Python
18.2%2
Python
18.2%2
3 min read0%
3 min read