Quick Reference

uv Quick Reference

Essential uv commands organized by workflow - project creation, dependency management, script execution, tool management, and more. Your complete uv cheatsheet.

Updated Mar 28, 2026 From pydevtools.com

This reference provides essential uv commands organized by workflow. For comprehensive documentation, visit the uv docs. Need help getting started? Check out how to install uv and create your first Python project.

Project Creation

CommandDescription
uv initInitialize new Python project in current directory with pyproject.toml
uv init myprojectCreate new project directory and initialize with project structure
uv init --packageCreate project to be built as Python package
uv init --appCreate application project
uv init --libCreate library project
uv init --scriptCreate single-file script
uv init --bareCreate only pyproject.toml file
uv init --python 3.12Specify Python version

Dependency Management

CommandDescription
uv add requestsAdd production dependency to project and update lockfile
uv add --dev pytestAdd development dependency for testing and development tools
uv add -r requirements.txtImport from requirements file (migration guide)
uv remove requestsRemove dependency
uv syncUpdate project environment and refresh lockfile with latest compatible versions
uv lockGenerate or update lockfile
uv lock --upgradeUpgrade all dependencies in lockfile
uv treeView dependency tree

Script Management

CommandDescription
uv init --script myscript.pyCreate single-file script with inline metadata
uv add --script myscript.py clickAdd dependency to script inline metadata
uv run myscript.pyExecute Python script in managed virtual environment with project dependencies
uv run --with requests myscript.pyRun script with temporary dependencies without adding to project

Want to learn about self-contained scripts? See how to write self-contained Python scripts.

Tool Management

CommandDescription
uvx pytestRun tool in ephemeral environment
uv tool install ruffInstall tool globally for system-wide use
uv tool listList installed tools
uv tool upgrade ruffUpdate specific tool
uv tool upgrade --allUpdate all tools

Python Version Management

CommandDescription
uv python listShow available Python versions
uv python install 3.12Download and install specific Python version for project use
uv python pin 3.12Pin project to specific Python version
uv run --python 3.12 pythonRun Python using specific version

Learn more about managing Python versions in uv projects and adding Python to your system PATH.

Building & Publishing

CommandDescription
uv buildBuild distribution packages
uv publishUpload to PyPI
uv publish --publish-url https://test.pypi.org/legacy/Upload to TestPyPI

Ready to publish? Follow our complete PyPI publishing guide.

Version Management

CommandDescription
uv versionShow current version
uv version --bump patchIncrement patch version
uv version --bump minorIncrement minor version
uv version --bump majorIncrement major version

Virtual Environments

CommandDescription
uv venvCreate virtual environment
uv venv --python 3.12Create with specific Python

New to virtual environments? Read why you should use a virtual environment.

Utility Commands

CommandDescription
uv --helpShow help
uv help syncHelp for specific command
uv self updateUpdate uv itself
uv cache cleanClear package cache

Common Workflows

New Project Setup

uv init myproject
cd myproject
uv add requests pandas
uv add --dev pytest ruff
uv run python main.py

Existing Project

git clone <repo>
cd <repo>
uv sync
uv run pytest

Need help with testing? Check out setting up testing with pytest and uv and how to run tests using uv.

Quick Script

uv init --script analyze.py
uv add --script analyze.py pandas matplotlib
uv run analyze.py

Configuration

pyproject.toml Essentials

[project]
name = "myproject"
version = "0.1.0"
dependencies = ["requests>=2.28.0"]

[tool.uv]
dev-dependencies = [
    "pytest>=7.0",
    "ruff>=0.1.0",
]

Environment Variables

Tips