Skip to main content
One of the best aspects of uv is that it removes most of the manual friction from virtual environment management. You no longer have to run separate commands to create a virtual environment, activate it, and then install packages. With uv, the environment is created automatically when you first add a package, activated transparently by uv run, and tracked in a lock file that makes the whole setup reproducible from a single command. This page walks you through everything you need to know to manage environments and packages the uv way.

Creating a new project

Start every new project with uv init. This creates a ready-to-use project structure in seconds:
uv creates the following files:
The .venv folder and uv.lock file do not exist yet — they are created automatically the first time you run uv add to install a package.

Understanding pyproject.toml

pyproject.toml is the modern standard for Python project configuration. It replaces requirements.txt, setup.py, setup.cfg, and other legacy files with a single, well-structured file:
As you add packages, the dependencies list updates automatically. You commit this file to version control so your team always knows what the project needs.

Adding packages

Install packages with uv add:
After running uv add requests pandas numpy, your pyproject.toml updates automatically:
At the same time, uv creates:
  • .venv/ — the virtual environment with all packages installed
  • uv.lock — the lock file with exact versions of every package and dependency

The lock file

uv.lock is one of uv’s most valuable features. It records the precise version of every package in your project — including the dependencies of your dependencies — so that uv sync always produces an identical environment:
Commit uv.lock to version control. Anyone who clones your repository can run uv sync and get an environment that matches yours exactly.

Running your code

With uv, you have three ways to execute Python:
Use uv run for scripts and automation. Use VS Code’s interpreter selector to pick .venv for interactive development — then VS Code manages activation for you.

Removing and updating packages

Reproducing an environment

When you clone a project that uses uv, get it running with a single command:
uv reads uv.lock, creates .venv, and installs every package at the exact pinned version. No need to manually create a virtual environment or figure out which packages to install.

Working with existing pip projects

If you are migrating a project that uses requirements.txt:

Common uv commands reference

Complete project setup

Walk through a complete end-to-end project setup with uv, Git, and GitHub.