Introducció
uv supports managing Python projects, which define their dependencies in a pyproject.toml file.
Creating a new project
You can create a new Python project using the uv init command:
Alternatively, you can initialize a project in the working directory:
uv will create the following files:
The main.py file contains a simple “Hello world” program. Try it out with uv run:
Project structure
A project consists of a few important parts that work together and allow uv to manage your project.
In addition to the files created by uv init, uv will create a virtual environment and uv.lock file in the root of your project the first time you run a project command, i.e., uv run, uv sync, or uv lock.
…
Managing dependencies
You can add dependencies to your pyproject.toml with the uv add command.
This will also update the lockfile and project environment:
Gestionat l’entorn virtual
Managing Python Virtual Environments with UV: A Comprehensive Guide