TExcelTAD
Home › Python Packaging: pip, venv, Poetry & uv › uv python: Managing Interpreters

uv python: Managing Interpreters

Before you can create an environment you need a Python interpreter, and the right one: the version your project supports, built for your platform. Traditionally that meant the OS package manager, the python.org installer, Homebrew, pyenv (compiling from source), or conda. uv adds its own answer: it can find interpreters already on the machine and download standalone builds (python-build-standalone) on demand.

Finding interpreters

bash · try it yourself
uv python list --only-installed
echo "--- the one uv would pick"
uv python find
uv python find 3.13
echo "--- a version that isn't here"
uv python find 3.12 2>&1
cpython-3.13.17-linux-x86_64-gnu    /usr/local/bin/python3.13 -> /opt/python/bin/python3.13
cpython-3.13.17-linux-x86_64-gnu    /usr/local/bin/python3 -> /opt/python/bin/python3
cpython-3.13.17-linux-x86_64-gnu    /usr/local/bin/python -> /opt/python/bin/python
--- the one uv would pick
/usr/local/bin/python
/usr/local/bin/python3.13
--- a version that isn't here
error: No interpreter found for Python 3.12 in virtual environments, managed installations, or search path

uv searches, in order: an active or project virtual environment, uv's own managed installs (~/.local/share/uv/python), then every python, python3 and python3.x on PATH (and the py launcher on Windows). This container has only CPython 3.13.17, reachable under three names.

Installing interpreters (not runnable here)

On a normal machine, this is what makes uv convenient: a missing Python is downloaded in a second or two, no compiler needed. The container used for this course has downloads disabled (UV_PYTHON_DOWNLOADS=never) and no network, so these commands are shown as sample output (version numbers and timings are illustrative):

bash
$ uv python install 3.12 3.14
Installed 2 versions in 3.21s
 + cpython-3.12.12-linux-x86_64-gnu
 + cpython-3.14.0-linux-x86_64-gnu

$ uv python list --only-installed
cpython-3.14.0-linux-x86_64-gnu     /home/ada/.local/share/uv/python/cpython-3.14.0-linux-x86_64-gnu/bin/python3.14
cpython-3.13.17-linux-x86_64-gnu    /usr/local/bin/python3.13
cpython-3.12.12-linux-x86_64-gnu    /home/ada/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/bin/python3.12

By default uv also downloads automatically when a command needs a version that isn't installed (python-downloads = "automatic"). Here the same request fails, and the hint names the setting:

bash · try it yourself
uv python install 3.12 2>&1
echo "---"
uv venv --python 3.12 2>&1
Python downloads are not allowed (`python-downloads = "never"`). Change to `python-downloads = "manual"` to allow explicit installs.
---
error: No interpreter found for Python 3.12 in managed installations or search path

hint: A managed Python download is available for Python 3.12, but Python downloads are set to 'never'

Tip: In locked-down CI or corporate environments you may want UV_PYTHON_DOWNLOADS=never (or python-downloads = "manual" in uv.toml): it guarantees uv only uses interpreters your image provides. UV_PYTHON_PREFERENCE=only-system and only-managed choose between the two sources.

Pinning a project's interpreter

Two settings work together:

File Setting Meaning
pyproject.toml requires-python = ">=3.13" the range the project supports; published in metadata, used for resolution
.python-version 3.13 the exact version developers and CI should use for this checkout; written by uv python pin
bash · try it yourself
uv init -q --no-package app && cd app
cat .python-version
uv python pin 3.13 2>&1
uv run python --version
echo "--- pin a version the project doesn't support"
uv python pin 3.12 2>&1
echo "--- or require a newer Python than this machine has"
sed -i 's/requires-python = ">=3.13"/requires-python = ">=3.14"/' pyproject.toml
rm .python-version
uv run python --version 2>&1
3.13
Pinned `.python-version` to `3.13`
Using CPython 3.13.17 interpreter at: /usr/local/bin/python3.13
Creating virtual environment at: .venv
Python 3.13.17
--- pin a version the project doesn't support
warning: No interpreter found for Python 3.12 in managed installations or search path
error: The requested Python version `3.12` is incompatible with the project `requires-python` value of `>=3.13`.
--- or require a newer Python than this machine has
error: No interpreter found for Python >=3.14 in managed installations or search path

hint: A managed Python download is available for Python >=3.14, but Python downloads are set to 'never'

uv checks both against each other: a pin outside requires-python is refused up front, and a requires-python that no available interpreter satisfies stops uv run before any environment is built.

Note: requires-python matters beyond your own machine. uv and Poetry lock for every Python in that range, so >=3.9 forces the resolver to find versions that also work on 3.9 (often older ones). Set it to what you actually test.

uv python vs pyenv vs the OS

OS packages pyenv uv python
Install speed fast slow (compiles) fast (prebuilt)
Many versions side by side awkward yes yes
Per-project version file no .python-version .python-version (compatible)
Who updates security fixes the distribution you you (install the newer patch release)
Good for system tools, servers managed by ops developers who already use it developers and CI using uv

Test yourself

What's the difference between requires-python and .python-version?

  1. They are the same
  2. requires-python is the supported range (published, used by resolvers); .python-version is the exact interpreter to use for this checkout
  3. .python-version is published to PyPI
  4. requires-python only affects uv

Where do interpreters installed by uv python install come from?

  1. Compiled from source
  2. Prebuilt python-build-standalone distributions downloaded by uv
  3. The OS package manager
  4. Conda

Why would a CI image set UV_PYTHON_DOWNLOADS=never?

  1. To make uv faster
  2. To guarantee uv uses only the interpreters the image provides, never a downloaded one
  3. Because downloads are illegal
  4. To disable the cache