PyO3/pyo3 · error

unknown interpreter: {}

Error message

unknown interpreter: {}

What it means

Parse error from the FromStr impl of PythonImplementation: the string being parsed (typically PYO3_CROSS_PYTHON_IMPLEMENTATION or a stored config value) did not exactly match one of the accepted names CPython/PyPy/GraalPy/RustPython — e.g. a typo, different casing, or free-form text like 'python3'.

Source

Thrown at pyo3-build-config/src/impl_.rs:1518

    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            PythonImplementation::CPython => write!(f, "CPython"),
            PythonImplementation::PyPy => write!(f, "PyPy"),
            PythonImplementation::GraalPy => write!(f, "GraalVM"),
            PythonImplementation::RustPython => write!(f, "RustPython"),
        }
    }
}

impl FromStr for PythonImplementation {
    type Err = Error;
    fn from_str(s: &str) -> Result<Self> {
        match s {
            "CPython" => Ok(PythonImplementation::CPython),
            "PyPy" => Ok(PythonImplementation::PyPy),
            "GraalVM" => Ok(PythonImplementation::GraalPy),
            "RustPython" => Ok(PythonImplementation::RustPython),
            _ => bail!("unknown interpreter: {}", s),
        }
    }
}

/// Checks if we should look for a Python interpreter installation
/// to get the target interpreter configuration.
///
/// Returns `false` if `PYO3_NO_PYTHON` environment variable is set.
fn have_python_interpreter() -> bool {
    env_var("PYO3_NO_PYTHON").is_none()
}

/// The target stable ABI version.
///
/// For abi3(t)-py* builds a specific version is chosen, otherwise the builds is
/// for the stable ABI exposed by the host python interpreter version.
#[derive(Debug, Copy, Clone)]
pub enum StableAbiVersion {

View on GitHub (pinned to ac9b6899d3)

Solutions

  1. Use exactly one of: CPython, PyPy, GraalPy, RustPython
  2. Check for whitespace or case differences in PYO3_CROSS_PYTHON_IMPLEMENTATION
  3. Prefer the canonical spelling emitted by pyo3-build-config itself
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pyo3-build-config/src/impl_.rs:1518 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of PyO3/pyo3@ac9b6899d3 (2026-09-05). Data as JSON: /api/errors/5d56e23c49ab3ac8. Report an issue: GitHub.