Skip to main content

Synopsis

Description

Search for a Python installation. Displays the path to the Python executable. See uv help python to view supported request formats and details on discovery behavior.

Arguments

[REQUEST]

The Python request. When not provided, the Python requirement of a project in the current directory or parent directories will be used (unless --no-project is specified). See uv help python to view supported request formats. Examples:
  • 3.12 - Find Python 3.12
  • cpython@3.11 - Find CPython 3.11
  • >=3.10 - Find Python 3.10 or newer
  • python3.12 - Find by executable name
  • /usr/bin/python3 - Find specific installation

Options

Discovery Options

--no-project

Avoid discovering a project or workspace. Otherwise, when no request is provided, the Python requirement of a project in the current directory or parent directories will be used. Aliases: --no-workspace

--system

Only find system Python interpreters. By default, uv will report the first Python interpreter it would use, including those in an active virtual environment or a virtual environment in the current working directory or any parent directory. The --system option instructs uv to skip virtual environment Python interpreters and restrict its search to the system path.
  • Environment variable: UV_SYSTEM_PYTHON
  • Conflicts with: --no-system

--no-system

Allow finding Python in virtual environments. This is the default behavior.
  • Conflicts with: --system

--script <SCRIPT>

Find the environment for a Python script, rather than the current project.
  • Type: Path
  • Conflicts with: request, --no-project, --system, --no-system

Display Options

--show-version

Show the Python version that would be used instead of the path to the interpreter. Example output: 3.12.4 instead of /usr/bin/python3.12 Resolve symlinks in the output path. When enabled, the output path will be canonicalized, resolving any symlinks. Example:
  • Without flag: /usr/bin/python3 (may be a symlink)
  • With flag: /usr/lib/python3.12/bin/python3.12 (resolved)

Custom Downloads

--python-downloads-json-url <PYTHON_DOWNLOADS_JSON_URL>

URL pointing to JSON of custom Python installations.
  • Type: String

Version Request Formats

The following Python version request formats are supported:
  • <version> e.g. 3, 3.12, 3.12.3
  • <version-specifier> e.g. >=3.12,<3.13
  • <version><short-variant> e.g., 3.13t, 3.12.0d
  • <version>+<variant> e.g., 3.13+freethreaded, 3.12.0+debug
  • <implementation> e.g. cpython or cp
  • <implementation>@<version> e.g. cpython@3.12
  • <implementation><version> e.g. cpython3.12 or cp312
  • <implementation><version-specifier> e.g. cpython>=3.12,<3.13
  • <implementation>-<version>-<os>-<arch>-<libc> e.g. cpython-3.12.3-macos-aarch64-none
Additionally, a specific system Python interpreter can often be requested with:
  • <executable-path> e.g. /opt/homebrew/bin/python3
  • <executable-name> e.g. mypython3
  • <install-dir> e.g. /some/environment/

Discovery Behavior

uv searches for Python in the following order:
  1. Active virtual environment - If a virtual environment is activated
  2. Local virtual environment - .venv in current or parent directories
  3. Project Python requirement - From pyproject.toml or .python-version (unless --no-project)
  4. Managed Python - Python versions installed by uv
  5. System Python - Python found in PATH
  6. Windows registry - On Windows only
With --system, steps 1-2 are skipped.

Output Format

Default (Path)

With —show-version

Not Found

Examples

Find default Python

Finds the Python version that uv would use in the current directory.

Find specific version

Find with version specifier

Finds a Python version matching the specifier.

Find PyPy

Find system Python only

Ignores any virtual environments and searches only system-installed Python.

Find and show version

Outputs just the version number instead of the full path.
Shows the actual installation path instead of symlinks.

Find for a specific script

Finds the Python that would be used to run my_script.py, considering inline script metadata.

Verify installation

Use in scripts

Check project Python

Shows which Python would be used for the project based on .python-version or pyproject.toml.

Find without project influence

Ignores project requirements and finds the default Python.

Find exact executable

Verifies and returns the path to a specific Python executable.

Use Cases

Verify Python availability

Install Python 3.12 if it’s not already available.

Get Python for external tools

Debug Python resolution

CI/CD validation

Compare installations

See Also