uv
Install
Pip:
pip install uv
Debian (not packaged for Debian yet) / generic:
curl -LsSf https://astral.sh/uv/install.sh | sh
Arch:
sudo pacman -S uv
Usage
Initialize in existing project (creates .python-version, pyproject.toml. hello.py):
uv init --no-workspace .
Add a dependency (creates virtualenv at: .venv):
uv add "ansible<10"
uv add "fints==5.0.0b1"
uv add "httpx @ git+https://github.com/encode/httpx"
uv add git+https://github.com/encode/httpx --branch main
uv add git+https://github.com/encode/httpx --tag 0.27.0
Add requirements from a requirements.txt file:
uv add -r requirements.txt
Update lockfile when i.e. adding dependencies manually to pyproject.toml:
uv lock
Install dependencies:
uv sync
venv
To run a cmd inside the venv:
uv run ansible
tools
- Using tools
- Tools are installed at
~/.local/share/uv/tools/
One-time running tool (both commands are equivalent):
uvx tool run ruff
uvx ruff
uv tool install ruff
ruff --version
Inline script metadata
- uv docs: Declaring script dependencies
- PEP 723 – Inline script metadata
- Create Project-Less Python Utilities with uv and Inline Script Metadata