If you want to start a new project:
uv init
This will create a .venv, a pyproject.toml (main project file) and uv.lock.
If the project already exists and has a requirements.txt with all the dependencies, from a freshly clone project do a uv init
as above and then:
uv add -r requirements.txt
This will import all the existing dependencies in pyproject.toml.
The environment created with init can be activated as usual with source .env/bin/activate
(and then deactivated with deactivate
) to use the local python directly, or you can simply call from now on:
uv run <script.py> <arguments>
Add new dependencies with a specific version with:
uv add '<dependency name>==x.y.z'
or simply
uv add <dependency name>
To keep the requirements.txt in line with the updated dependencies run uv pip freeze > requirements.txt
.
Remove dependencies with uv remove <dependency name>
.
A local python version can be set with:
uv python install 3.14
To list the versions available for download and the versions already installed throughout the system run:
uv python list
To change the currently selected python version, pin it:
uv python pin 3.14
And update the minimum supported version in pyproject.toml
if needed.
The official documentation is available here: https://docs.astral.sh/uv/