The UV package manager

We will setup a Python environment using the UV package manager

In modern Python development, managing dependencies and environments can quickly become a source of friction, especially as projects grow in complexity. The UV package manager offers a streamlined approach to handling these concerns by combining robust dependency resolution, lightweight virtual environment management, and intuitive project configuration into a single tool. Whether you’re starting a new data-driven analysis or building a deep learning pipeline with PyTorch, UV simplifies the initial setup and ongoing maintenance of your workspace, so you can focus on writing code rather than wrestling with version conflicts.

This guide will walk you through the entire process of creating a fresh Python project using UV. We’ll begin by exploring what UV is and why it represents a substantial improvement over traditional tools like pip and Conda. You’ll learn how to initialize a project directory, customize your pyproject.toml configuration using the TOML format, and leverage UV’s built-in commands to create and activate an isolated virtual environment. Along the way, we’ll install essential data science libraries—NumPy, Pandas, Matplotlib, Seaborn, and JupyterLab—and show you how to add PyTorch with the appropriate build for your system. By the end of this tutorial, you’ll have a fully functional, reproducible development setup that you can replicate across machines or share with your team in seconds.

What Is the UV Package Manager?

UV is a modern, high-performance Python package manager written in Rust and developed by Astral, the team best known for the Ruff linter, designed to streamline dependency resolution, environment management, and even Python interpreter installation into a single, unified tool .

UV is engineered as a drop-in replacement for both pip and pip-tools, offering blazing-fast dependency resolution and installation speeds that routinely outperform traditional Python tooling by an order of magnitude or more . Under the hood, UV leverages a global module cache to deduplicate dependencies across projects and employs copy-on-write and hardlink techniques on supported file systems to minimize disk usage and eliminate redundant downloads . Its command-line interface mirrors familiar pip commands—such as uv pip compile, uv pip sync, and uv venv—enabling developers to adopt UV in existing workflows with zero configuration changes while gaining advanced capabilities like Git and URL dependencies, constraint files, and custom package indexes .

Beyond package installation, UV provides native cross-platform support for Linux, macOS, and Windows, and uniquely manages Python interpreter versions itself, automatically downloading and installing the appropriate builds on demand . Unlike pip, which is implemented in Python and can suffer performance bottlenecks and subtle dependency conflicts, and Conda, which relies on large, distribution-focused repositories for both Python and non-Python packages, UV’s Rust-based implementation delivers memory-safe, high-throughput performance and precise dependency resolution through a modern resolver design . UV’s architecture is grounded in three core principles: an obsessive focus on performance, modularity that allows its pip-compatible API to function as a comprehensive project manager or as standalone resolver/environment creator, and a simplified toolchain delivered as a single static binary without direct Python dependencies .

By consolidating package installation, virtual environment creation, and Python version management into one cohesive tool, UV simplifies project setup and ensures reproducibility across machines, making it an increasingly compelling choice for modern Python development workflows . Since its initial release in early 2024, UV has seen rapid adoption and community interest—achieving over a million installs per day and attracting contributors seeking a reliable, high-speed alternative to legacy packaging tools.

Advantages of UV vs. pip and Conda

UV delivers exceptional performance and responsiveness, transforming the way Python dependencies are installed and managed. Under the hood, its Rust-based resolver executes dependency analysis in parallel, outperforming the Python-based pip by up to 10× without cache and reaching 80–115× faster with a warm cache on typical workloads . Unlike Conda, which is built around large binary repositories and can incur significant overhead, UV ships as a single static binary with no direct Python dependencies, offering a lean memory footprint and rapid startup time . A key innovation in UV is its global module cache, which deduplicates package downloads and leverages copy-on-write and hardlinking to minimize disk usage across multiple environments .

Beyond raw speed and storage efficiency, UV’s modern resolver adheres strictly to Python packaging standards while generating universal lockfiles that are portable across operating systems, architectures, and Python versions, greatly simplifying collaboration in diverse development teams . By default, UV enforces the use of isolated virtual environments, creating venvs up to 80× faster than the standard python -m venv and 7× faster than virtualenv, guaranteeing environment isolation without sacrificing convenience . Its command-line interface mirrors familiar pip commands—such as uv pip install, uv pip compile, and uv pip sync—while also supporting advanced workflows like Git and URL dependencies, constraint files, and script management, enabling seamless adoption with zero-bounce integration into existing projects . Finally, UV uniquely incorporates Python interpreter management, automatically downloading and installing required Python versions on demand and eliminating the need for separate tools like Pyenv or Conda to handle interpreter versions .

Last updated