Skip to main content

Overview

uv supports managing Python projects with dependencies defined in pyproject.toml. This guide covers the full workflow from initialization to deployment.

Creating a new project

You can create a new Python project using uv init:
uv creates the following files:
Test your new project:

Project structure

After running your first project command (uv run, uv sync, or uv lock), uv creates additional files:

Key files explained

Contains your project’s dependencies and metadata:
You can edit this file manually or use commands like uv add and uv remove.
See the official pyproject.toml guide for more details.
Specifies the default Python version for your project. uv uses this file to determine which Python version to use when creating the virtual environment.
Contains your project’s isolated Python environment where dependencies are installed. See the project environment documentation for more details.
A cross-platform lockfile with exact dependency versions. Unlike pyproject.toml (which specifies broad requirements), the lockfile contains exact resolved versions.This file is human-readable TOML but managed by uv — don’t edit it manually.
Always commit uv.lock to version control for consistent installations across machines.

Managing dependencies

1

Add a dependency

Add packages to your project with uv add:
This updates pyproject.toml, uv.lock, and your virtual environment.
2

Add version constraints

Specify version constraints or alternative sources:
3

Migrate from requirements.txt

Import all dependencies from an existing requirements file:
4

Remove dependencies

Remove packages you no longer need:
5

Upgrade packages

Update specific packages to the latest compatible version:
The --upgrade-package flag updates the specified package while keeping the rest of the lockfile intact.

Running commands

uv run executes scripts or commands in your project environment:
uv run automatically syncs your environment before execution, ensuring dependencies match uv.lock.

Using the project environment directly

Alternatively, manually sync and activate the environment:
The virtual environment must be active to run scripts without uv run. Activation differs per shell and platform.

Viewing your version

Check your package version:
See the publishing guide for details on updating your version.

Building distributions

Build source distributions and wheels for your project:
By default, artifacts are placed in a dist/ subdirectory:
See the building projects documentation for more details.

Complete workflow example

Here’s a complete project workflow from initialization to building:
1

Initialize project

2

Add dependencies

3

Write your code

Create your application in main.py:
4

Run your application

5

Add development dependencies

6

Build for distribution

Next steps

Projects concept

Learn more about how uv projects work

Export lockfiles

Export to different formats

Running scripts

Learn about standalone Python scripts

Command reference

View all uv commands