PyO3/pyo3 · error
Detected multiple possible Python versions. Please set eithe
Error message
Detected multiple possible Python versions. Please set either the PYO3_CROSS_PYTHON_VERSION variable to the wanted version or the _PYTHON_SYSCONFIGDATA_NAME variable to the wanted sysconfigdata file name. sysconfigdata files found:
What it means
Error "Detected multiple possible Python versions. Please set either the PYO3_CROSS_PYTHON_VERSION variable to the wanted version or the _PYTHON_SYSCONFIGDATA_NAME variable to the wanted sysconfigdata file name. sysconfigdata files found:" thrown in PyO3/pyo3.
Source
Thrown at pyo3-build-config/src/impl_.rs:2063
if sysconfig_paths.is_empty() {
if let Some(lib_dir) = cross.lib_dir.as_ref() {
bail!("Could not find _sysconfigdata*.py in {}", lib_dir.display());
} else {
// Continue with the default configuration when PYO3_CROSS_LIB_DIR is not set.
return Ok(None);
}
} else if sysconfig_paths.len() > 1 {
let mut error_msg = String::from(
"Detected multiple possible Python versions. Please set either the \
PYO3_CROSS_PYTHON_VERSION variable to the wanted version or the \
_PYTHON_SYSCONFIGDATA_NAME variable to the wanted sysconfigdata file name.\n\n\
sysconfigdata files found:",
);
for path in sysconfig_paths {
use std::fmt::Write;
write!(&mut error_msg, "\n\t{}", path.display()).unwrap();
}
bail!("{}\n", error_msg);
}
Ok(Some(sysconfig_paths.remove(0)))
}
/// Finds `_sysconfigdata*.py` files for detected Python interpreters.
///
/// From the python source for `_sysconfigdata*.py` is always going to be located at
/// `build/lib.{PLATFORM}-{PY_MINOR_VERSION}` when built from source. The [exact line][1] is defined as:
///
/// ```py
/// pybuilddir = 'build/lib.%s-%s' % (get_platform(), sys.version_info[:2])
/// ```
///
/// Where get_platform returns a kebab-case formatted string containing the os, the architecture and
/// possibly the os' kernel version (not the case on linux). However, when installed using a package
/// manager, the `_sysconfigdata*.py` file is installed in the `${PREFIX}/lib/python3.Y/` directory.
/// The `_sysconfigdata*.py` is generally in a sub-directory of the location of `libpython3.Y.so`.View on GitHub (pinned to ac9b6899d3)
Solutions
- Set PYO3_CROSS_PYTHON_VERSION to the exact wanted version, e.g. 3.12
- Or set _PYTHON_SYSCONFIGDATA_NAME to the specific sysconfigdata file name (e.g. _sysconfigdata__linux_x86_64-linux-gnu.py)
- Remove extraneous _sysconfigdata*.py files from the cross lib dir so only one candidate remains
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pyo3-build-config/src/impl_.rs:2063 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/d62678584f134b8d.
Report an issue: GitHub.