uv Cheatsheet — Python Management
Install Python Versions
uv downloads pre-built CPython distributions from Astral’s python-build-standalone project. No compilation needed.
# Install the latest Python
uv python install
# Install specific versions
uv python install 3.12
uv python install 3.12 3.13 3.14
# Install a precise patch version
uv python install 3.12.8
# Install a default `python` / `python3` executable (experimental)
uv python install --defaultInstalled Python executables land in ~/.local/bin/ (e.g., python3.12). If this isn’t in your $PATH:
uv python update-shellList Available & Installed Versions
# Show installed versions
uv python list
# Show only uv-managed versions
uv python list --only-managedPin a Project to a Python Version
# Creates / updates .python-version
uv python pin 3.12
# Pin to an exact version
uv python pin 3.12.8The .python-version file is respected by uv run, uv sync, and uv venv. For projects requiring multiple versions (e.g., for tox-style testing), use a .python-versions file (one version per line).
Use a Specific Version Ad-Hoc
# Create a venv with a specific version
uv venv --python 3.13
# Run a command with a specific version
uv run --python 3.11 -- python -c "import sys; print(sys.version)"
# Even use alternative implementations
uv run --python pypy@3.10 -- python --versionUpgrade Patch Versions (preview)
# Upgrade to the latest patch release (e.g., 3.13.4 → 3.13.5)
uv python upgrade 3.13Minor version upgrades (e.g., 3.12 → 3.13) are not transparent upgrades because they can affect dependency resolution.
Reinstall Managed Python
uv python install --reinstallUseful when a new build of the same version fixes bugs.
Automatic Downloads
By default, uv auto-downloads Python when it’s needed. For example, running uv venv on a machine with no Python will trigger an automatic install. To disable this:
# Disable automatic downloads
export UV_PYTHON_DOWNLOADS=never
# Or per-command
uv run --no-managed-python main.pyForce System Python
# Ignore uv-managed versions, use only system-installed Python
uv run --no-managed-python -- python --versionKey Directories
| What | Default path (Linux) |
|---|---|
| Managed Python installs | ~/.local/share/uv/python/ |
| Python executables | ~/.local/bin/ |
Override the install dir with UV_PYTHON_INSTALL_DIR.