astral-sh/uv · error · anyhow::Error

The requested interpreter resolved to Python {}, which is in

Error message

The requested interpreter resolved to Python {}, which is incompatible with the `pylock.toml`'s Python requirement: `{}`

What it means

Error "The requested interpreter resolved to Python {}, which is incompatible with the `pylock.toml`'s Python requirement: `{}`" thrown in astral-sh/uv.

Source

Thrown at crates/uv/src/commands/pylock.rs:73

    Ok((install_path, lock))
}

/// Verify Python compatibility and convert a parsed [`PylockToml`] into a [`Resolution`] with its
/// [`HashStrategy`].
pub(crate) fn resolve_pylock_toml(
    lock: PylockToml,
    install_path: &Path,
    interpreter: &Interpreter,
    python_version: Option<&PythonVersion>,
    python_platform: Option<&TargetTriple>,
    extras: &[ExtraName],
    groups: &[GroupName],
    build_options: &BuildOptions,
    hash_checking: Option<HashCheckingMode>,
) -> anyhow::Result<(Resolution, HashStrategy)> {
    if let Some(requires_python) = lock.requires_python.as_ref() {
        if !requires_python.contains(interpreter.python_version()) {
            return Err(anyhow::anyhow!(
                "The requested interpreter resolved to Python {}, which is incompatible with the `pylock.toml`'s Python requirement: `{}`",
                interpreter.python_version(),
                requires_python,
            ));
        }
    }

    let tags = resolution_tags(python_version, python_platform, interpreter)?;
    let marker_env = resolution_markers(python_version, python_platform, interpreter);

    let resolution = lock.to_resolution(
        install_path,
        marker_env.markers(),
        extras,
        groups,
        &tags,
        build_options,
    )?;

View on GitHub (pinned to f1a42680ff)

When it happens

Trigger: Thrown at crates/uv/src/commands/pylock.rs:73 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astral-sh/uv@f1a42680ff (2026-08-16). Data as JSON: /api/errors/c1a32456314c5183. Report an issue: GitHub.