Skip to content

Instantly share code, notes, and snippets.

@franTarkenton
Last active December 13, 2024 16:40
Show Gist options
  • Save franTarkenton/804fcc3fce561d7a5d848908a07f3fd3 to your computer and use it in GitHub Desktop.
Save franTarkenton/804fcc3fce561d7a5d848908a07f3fd3 to your computer and use it in GitHub Desktop.
Cookbook on using UV

UV: Overview

python has a lot of different options that can be used to help manage dependencies including:

  • pip / venv
  • pipenv
  • conda / anaconda / miniconda
  • mamba / micromamba
  • poetry
  • ... and now uv

Below is my cheat sheet for some common things you may want to do using UV.

Cheatest Sheetest

Install uv:

python3.13 -m pip install uv

Create the initial project

uv init data-query-tool

add a new package dependency

uv add requests

install dependencies defined in lock file

uv sync

update/recreate the lock file from what is defined in pyproject.toml

uv lock

Install dev dependencies

uv add ruff --dev

Uv cache directory

uv python dir

Tool cache directory

uv tool dir

Activate env

. .venv/bin/activate

Use tool without installing

uvx toolname

Upgrade a specific dependency

uv lock --upgrade-package requests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment