uv Commands
Complete reference for uv, the fast Python package manager. Covers project management, Python version control, pip-compatible interface, configuration, and practical workflows with searchable cards and one-click copy.
How to UseExpand how to useCollapse how to use
- 1
Filter by category
Switch between Project, Python & Tools, pip-Compatible, Config, and Workflow to focus on the commands you need.
- 2
Search details
Use keyword search to match command names, option notes, and example commands at once.
- 3
Copy and run
Copy the command snippet with one click, then run it directly in your terminal.
uv run
Key points
- --with <pkg>: Temporarily add a package for this run.
- --python <ver>: Run with a specific Python version.
Examples
uv run python app.pyRun a script in the project's virtual environment.uv run --with requests python fetch.pyTemporarily add requests and run the script.uv init
Key points
- --name <name>: Set the project name.
- --python <ver>: Specify the Python version to use.
Examples
uv init my-projectCreate a new project in the my-project directory.uv init --python 3.12Initialize a project with Python 3.12.uv add
Key points
- --dev: Add as a development dependency.
- --optional <group>: Add to an optional dependency group.
Examples
uv add flaskAdd Flask as a dependency.uv add --dev pytest ruffAdd pytest and ruff as dev dependencies.uv remove
Key points
- --dev: Remove from development dependencies.
- --optional <group>: Remove from an optional dependency group.
Examples
uv remove flaskRemove Flask from dependencies.uv remove --dev pytestRemove pytest from dev dependencies.uv sync
Key points
- --frozen: Sync without updating the lockfile.
- --no-dev: Exclude development dependencies.
Examples
uv syncSync the environment with the lockfile.uv sync --frozen --no-devCI-friendly: sync production deps only with frozen lock.uv lock
Key points
- --upgrade: Upgrade all packages to latest versions.
- --upgrade-package <pkg>: Upgrade a specific package only.
Examples
uv lockRegenerate the lockfile.uv lock --upgrade-package flaskUpgrade only Flask in the lockfile.uv export
Key points
- --format requirements-txt: Export as requirements.txt.
- --no-dev: Exclude development dependencies.
Examples
uv export --format requirements-txt > requirements.txtExport as requirements.txt.uv export --format requirements-txt --no-devExport production deps only.uv tree
Key points
- --depth <n>: Limit tree depth.
- --invert: Show reverse dependencies.
Examples
uv treeDisplay the dependency tree.uv tree --depth 1Show direct dependencies only.uv version
Key points
- --bump <type>: Bump major/minor/patch version.
- --output-format json: Output as JSON.
Examples
uv versionDisplay the current version.uv version --bump minorBump the minor version.uv venv
Key points
- --python <ver>: Specify the Python version.
- --seed: Pre-install pip, setuptools, and wheel.
Examples
uv venvCreate a virtual environment in .venv.uv venv --python 3.12 .venv312Create with Python 3.12 in a custom directory.uv build
Key points
- --sdist: Build source distribution only.
- --wheel: Build wheel only.
Examples
uv buildBuild both sdist and wheel.uv build --wheelBuild wheel only.uv publish
Key points
- --token <token>: Specify the PyPI API token.
- --publish-url <url>: Set a custom repository URL.
Examples
uv publishUpload distributions from dist/ to PyPI.uv publish --publish-url https://test.pypi.org/legacy/Upload to TestPyPI.uv format
Key points
- --check: Check if formatting changes are needed.
- --diff: Show formatting diff.
Examples
uv formatFormat all Python files in the project.uv format --checkCheck for formatting violations.uv python install
Key points
- uv python install 3.12: Install a specific version.
- uv python install 3.11 3.12: Install multiple versions.
Examples
uv python install 3.12Install Python 3.12.uv python install 3.11 3.12 3.13Install three versions at once.uv python list
Key points
- --all-versions: Show all minor versions.
- --only-installed: Show installed versions only.
Examples
uv python listList available Python versions.uv python list --only-installedShow only installed versions.uv python find
Key points
- uv python find 3.12: Find a 3.12 interpreter.
- uv python find cpython: Find a CPython interpreter.
Examples
uv python find 3.12Show the path to Python 3.12.uv python findShow the default Python interpreter path.uv python pin
Key points
- Records the version in .python-version.
- --resolved: Pin with the full version string.
Examples
uv python pin 3.12Pin to Python 3.12 (writes .python-version).uv python pin 3.12 --resolvedPin with the fully resolved version string.uv python uninstall
Key points
- uv python uninstall 3.11: Remove a specific version.
- --all: Remove all managed Python versions.
Examples
uv python uninstall 3.11Uninstall Python 3.11.uv python uninstall --allRemove all uv-managed Python versions.uv python upgrade
Key points
- uv python upgrade 3.12: Upgrade 3.12 to latest patch.
- Updates within the same minor version (3.12.x → 3.12.y).
Examples
uv python upgrade 3.12Upgrade Python 3.12 to the latest patch.uv python upgradeUpgrade all installed Python versions.uv python dir
Key points
- Outputs the path to managed Python binaries.
- Configurable via the UV_PYTHON_DIR environment variable.
Examples
uv python dirShow the Python installation directory.ls $(uv python dir)List installed Python versions.uv tool run
Key points
- uvx <command>: Shortcut for uv tool run.
- --from <pkg>: Specify the providing package explicitly.
Examples
uvx ruff check .Run ruff linter without installing.uvx --from black black --check .Run black formatter check.uv tool install
Key points
- Installs in an isolated environment per tool.
- --python <ver>: Specify the Python version for the tool.
Examples
uv tool install ruffInstall ruff as a global tool.uv tool install 'httpie>=3.0'Install httpie with version constraints.uv tool upgrade
Key points
- uv tool upgrade <tool>: Upgrade a specific tool.
- --all: Upgrade all installed tools.
Examples
uv tool upgrade ruffUpgrade ruff to the latest version.uv tool upgrade --allUpgrade all installed tools at once.uv tool list
Key points
- Shows tool name, version, and provided commands.
- --show-paths: Include installation paths.
Examples
uv tool listList all installed tools.uv tool list --show-pathsList tools with their installation paths.uv tool uninstall
Key points
- uv tool uninstall <tool>: Remove a specific tool.
- --all: Remove all installed tools.
Examples
uv tool uninstall ruffUninstall ruff.uv tool uninstall --allRemove all installed tools.uv tool dir
Key points
- Outputs the path to tool environments and binaries.
- --bin: Show the binary link directory.
Examples
uv tool dirShow the tool installation directory.uv tool dir --binShow the tool binary PATH directory.uv tool update-shell
Key points
- Automatically updates bash/zsh/fish configuration.
- Recommended after uv tool install.
Examples
uv tool update-shellAdd the tool directory to shell PATH.uv tool install ruff && uv tool update-shellInstall a tool and update PATH.uv pip install
Key points
- -r requirements.txt: Install from a requirements file.
- --system: Install into the system Python.
Examples
uv pip install flaskInstall Flask (10-100x faster than pip).uv pip install -r requirements.txtInstall from a requirements file.uv pip uninstall
Key points
- uv pip uninstall <pkg>: Remove a specific package.
- -r requirements.txt: Remove packages listed in a file.
Examples
uv pip uninstall flaskUninstall Flask.uv pip uninstall flask sqlalchemyUninstall multiple packages.uv pip compile
Key points
- -o requirements.txt: Specify the output file.
- --upgrade: Upgrade all packages and recompile.
Examples
uv pip compile requirements.in -o requirements.txtCompile a locked requirements file.uv pip compile pyproject.toml -o requirements.txtCompile from pyproject.toml.uv pip sync
Key points
- Automatically removes packages not in the file.
- Accepts multiple requirements files.
Examples
uv pip sync requirements.txtSync environment to match requirements.txt exactly.uv pip sync requirements.txt dev-requirements.txtSync with production and dev dependencies.uv pip freeze
Key points
- Outputs in pinned format (pkg==version).
- Equivalent to pip freeze output.
Examples
uv pip freezeList installed packages in requirements format.uv pip freeze > requirements.txtSave as requirements.txt.uv pip list
Key points
- --format json: Output as JSON.
- --outdated: Show only packages with available updates.
Examples
uv pip listList installed packages in table format.uv pip list --format jsonOutput the package list as JSON.uv pip show
Key points
- Displays version, dependencies, and install location.
- Accepts multiple package names.
Examples
uv pip show flaskShow details about Flask.uv pip show flask sqlalchemyShow details for multiple packages.uv pip tree
Key points
- --depth <n>: Limit tree depth.
- --invert: Show reverse dependencies.
Examples
uv pip treeDisplay the full dependency tree.uv pip tree --depth 1Show direct dependencies only.uv pip check
Key points
- Detects version conflicts and missing dependencies.
- Ideal for CI pipeline quality checks.
Examples
uv pip checkCheck environment consistency.uv pip sync requirements.txt && uv pip checkSync and verify consistency.uv cache clean
Key points
- uv cache clean: Remove all cached data.
- uv cache clean <pkg>: Remove cache for a specific package.
Examples
uv cache cleanClear all uv cache.uv cache clean flaskClear cache for Flask only.uv cache prune
Key points
- Selectively removes old and unused cache entries.
- Saves disk space while keeping useful cache.
Examples
uv cache pruneRemove unused cache entries.uv cache prune && uv cache dirPrune and check the cache directory.uv cache dir
Key points
- Configurable via the UV_CACHE_DIR environment variable.
- Defaults to the OS standard cache directory.
Examples
uv cache dirShow the cache directory path.du -sh $(uv cache dir)Check cache size.uv self update
Key points
- uv self update: Update to the latest stable release.
- uv self update <ver>: Update to a specific version.
Examples
uv self updateUpdate uv to the latest version.uv self update 0.7.0Update uv to version 0.7.0.uv auth login
Key points
- uv auth login <url>: Log in to the specified registry.
- --token <token>: Provide a token directly.
Examples
uv auth login https://pypi.orgLog in to PyPI.uv auth login https://private.registry.com --token $TOKENLog in to a private registry with a token.uv auth logout
Key points
- uv auth logout <url>: Remove credentials for a registry.
- Credentials are removed from the OS keychain.
Examples
uv auth logout https://pypi.orgRemove PyPI credentials.uv auth logout https://private.registry.comRemove private registry credentials.uv generate-shell-completion
Key points
- Supports bash, zsh, fish, and PowerShell.
- Add the generated script to your shell config.
Examples
uv generate-shell-completion zsh > ~/.zfunc/_uvGenerate zsh completion script.uv generate-shell-completion bash >> ~/.bashrcAdd bash completion to .bashrc.uv run --with <package> <script.py>
Key points
- --with: Use packages temporarily without adding to project.
- Multiple --with flags for multiple packages.
Examples
uv run --with requests python fetch.pyRun with requests temporarily added.uv run --with pandas --with matplotlib python analyze.pyRun an analysis script with pandas and matplotlib.uv pip compile requirements.in -o requirements.txt
Key points
- uv pip compile is a drop-in replacement for pip-compile.
- Existing requirements.in files work as-is.
Examples
uv pip compile requirements.in -o requirements.txtReplace pip-compile with uv.uv pip sync requirements.txtReplace pip-sync with uv.uv sync --frozen --no-dev
Key points
- --frozen: Keep the lockfile unchanged for CI stability.
- --no-dev: Production deps only for faster builds.
Examples
uv sync --frozen --no-devFast CI install with production deps only.uv sync --frozen && uv run pytestSync dependencies and run tests.uv run --python 3.12 pytest
Key points
- --python: Switch Python version per run.
- Can replace tox/nox for simple multi-version testing.
Examples
uv run --python 3.11 pytestRun tests with Python 3.11.uv run --python 3.12 pytest && uv run --python 3.13 pytestRun tests sequentially on 3.12 and 3.13.uvx ruff check .
Key points
- npx-like experience for Python tools.
- Always uses the latest version automatically.
Examples
uvx ruff check .Run ruff linter without installing.uvx black --check .Run black format check.uv export --format requirements-txt > requirements.txt
Key points
- Generate Docker-compatible requirements from uv projects.
- Combine with multi-stage builds for optimization.
Examples
uv export --format requirements-txt > requirements.txtGenerate requirements.txt for Docker.uv export --format requirements-txt --no-dev > requirements.txtExport production deps only.About uv Commands
uv is an extremely fast Python package manager built by Astral. Written in Rust, it unifies pip, pip-tools, poetry, and pyenv into a single tool with 10-100x speed improvements. This reference organizes all uv commands by category with practical examples.
Features
- All 49 uv commands organized by category
- Options and practical examples for each command
- Cross-search across commands, options, and examples
- One-click copy for any command
- Migration workflows from pip/poetry included
Use Cases
- Quick reference for uv commands during development
- Migrating from pip or poetry to uv
- Setting up uv in CI/CD pipelines
- Managing multiple Python versions with uv
- Using uv with Docker environments
FAQ
What is the difference between uv and pip?
uv is a Rust-based package manager that is 10-100x faster than pip. It provides a pip-compatible interface (uv pip install, etc.) while also integrating project management (uv add/sync) and Python version management (uv python install).
Can uv replace pip, poetry, and pyenv entirely?
Yes. uv provides package installation (pip replacement), dependency locking (pip-tools/poetry replacement), Python version management (pyenv replacement), and tool execution (pipx replacement) in a single tool.
Can I use my existing requirements.txt and pyproject.toml?
Yes. uv pip install reads requirements.txt files directly. For pyproject.toml, uv supports both its own format and existing PEP 621-compliant files.
What is the difference between uvx and npx?
uvx is the Python equivalent of npx. It runs commands from Python packages without installing them globally. For example, uvx ruff check . runs ruff without installation.
What are the benefits of using uv in CI/CD?
uv's fast installation speed significantly reduces CI setup time. Use uv sync --frozen --no-dev to build reproducible production environments quickly.
