Supercharge Your Python project with UV: The Lightning-Fast Package Manager
Published in:2025-04-16 | Category: Backend
Words: 969 | Reading time: 6min

Python’s ecosystem thrives on its rich library of packages, but managing dependencies can sometimes feel sluggish, especially in large projects. Enter UV, a modern package manager and resolver designed to supercharge your workflow. Developed by Astral (the team behind the popular Ruff linter), UV promises blazing speed and seamless integration with existing Python tools. Let’s explore why UV might become your new go-to for dependency management.

What is UV?

UV is a Rust-powered tool that combines a package installer (pip) and virtual environment manager (venv) into one ultra-fast solution. It aims to replace traditional tools like pip, pipenv, and poetry while staying fully compatible with their workflows. By leveraging Rust’s performance advantages, UV dramatically reduces installation and resolution times—often by 10-100x compared to older tools.

Why Use UV?

Speed: UV resolves and installs dependencies in seconds, even for complex projects.
Simplicity: It’s a drop-in replacement for pip and venv, requiring no workflow changes.
Modern Features: Supports pyproject.toml, lock files, and advanced dependency resolution.
Cross-Platform: Works on Windows, macOS, and Linux.

Getting Started with UV

Installation

UV is distributed as a static binary, so installation is straightforward:

1
pip install uv

Or use curl (Mac/Linux only)

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

Once the installation is complete, you can verify the installation by running:

1
uv --version
UV versionUV version
UV version

Running below command to get the help message:

1
uv --help
UV helpUV help
UV help

Creating a Project

To create a new project with UV, run:

1
uv init <project-name>

This will create a new project called directory with a pyproject.toml file and a uv.lock file. The pyproject.toml file is where you can specify your project’s dependencies and other metadata. The uv.lock file is where UV stores the resolved dependencies and their versions.

Let’s create a new project called uv-sample:

1
uv init uv-sample
UV init projectUV init project
UV init project

It also creates associated with the git for this project, .python-version file for managing Python version, and a sample main.py python file.

Project files generated by UV initProject files generated by UV init
Project files generated by UV init

The pyproject.toml file is where you can specify your project’s dependencies and other metadata. Since this project doesn’t have any dependencies, so the uv.lock file is empty. Below is uv-sample pyproject.toml file:

1
2
3
4
5
6
7
[project]
name = "uv-sample"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = []

Manage Dependencies

Using uv to manage dependencies is as simple as adding them to the dependencies section of the pyproject.toml file. For example, to add pandas as a dependency, we can run:

1
uv add pandas
UV Add dependencyUV Add dependency
UV Add dependency

From the screenshot, you can see before adding the dependency in python project. The uv also help us to create a virtual environment for our project. The package and dependencies installed in the virtual environment will be isolated from the system-wide packages.

The uv.lock file will be updated with the installed dependencies and their versions. And the pyproject.toml file will be updated with the new dependency.

pyproject.toml file after adding pandas as a dependency:

1
2
3
4
5
6
7
8
9
[project]
name = "uv-sample"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"pandas>=2.2.3",
]

uv.lock file is like a package-lock.json file for npm or yarn. It contains the resolved dependencies and their versions. We can see the installed dependencies and their versions in the uv.lock file. Please don’t edit this file manually.

To see the dependencies tree, we can run uv tree command.

1
uv tree
Dependencies via UV treeDependencies via UV tree
Dependencies via UV tree

It lists all the dependencies and their dependencies recursively.

UV lock fileUV lock file
UV lock file

You can also remove the dependency by running: uv remove <dependency-name>

1
uv remove pandas

If your project is cloned. And you want to setup the development environment on your local. You can run uv sync to install the dependencies from the uv.lock file.

1
uv sync
Install dependencies from UV syncInstall dependencies from UV sync
Install dependencies from UV sync

See, it’s very easy. It created a virtual environment for our project and installed the dependencies from the uv.lock file.

The uv has more features like using uv to install and select specific python verison, run the python code.

Manage Python Version

Using the uv also can manage the python version for your project. Below is the snapshot to manage the python.

UV pythonUV python
UV python

List all the available downloaded python.

1
uv python list
List of python versionsList of python versions
List of python versions

You can download and install the specific python version.

1
uv python install <version>

Let’s install the python version 3.14. See below screenshot.

1
uv python install 3.14
Install python versionInstall python version
Install python version

So using uv we can manage multiple python versions at same time. It’s like nvm for node.js. For more using uv to manage the python version, you can type uv python --help to get the help message.

Run Python Code

Before uv, we running the python code usuallly by using python <python-file>. In uv, we can run the python code using uv run command.

main.py example file.

1
2
3
4
5
6
def main():
print("Hello from uv-sample!")


if __name__ == "__main__":
main()

Executing below command to run the python code.

1
uv run main.py
Run python codeRun python code
Run python code

Summary

UV is a modern package manager and resolver designed to supercharge your workflow. It promises blazing speed and seamless integration with existing Python tools. It’s a drop-in replacement for pip and venv, requiring no workflow changes. It works on Windows, macOS, and Linux.

Prev:
Switching Tomcat with Jetty in Spring Boot Easily
Next:
Understanding the Model Context Protocol (MCP)