Skip to content

UV commands

Shamik edited this page Mar 19, 2026 · 1 revision

UV commands

Installing PyTorch

Add the following to the pyproject.toml for PyTorch gpu

[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu118" or "https://download.pytorch.org/whl/cpu"
explicit = true

Install PyTorch

uv add torch --index https://download.pytorch.org/whl/cpu

Adding specific projects in a custom made group

uv add pandas --group <name>

Creating a project with a specific python version

uv init hello_world -p 3.12

Running commands without modifying the lock file

uv sync/run --frozen  

Update the lock file

uv lock

Update all packages

uv lock -U

Check if the lock file matches the project metadata

uv sync --locked

Pinning a project to a specific python version

Navigate to inside the project directory

uv python pin <python version>

Adjusting python preferences

https://docs.astral.sh/uv/concepts/python-versions/#adjusting-python-version-preferences

Command reference

https://docs.astral.sh/uv/reference/cli/

Clone this wiki locally