PyO3/pyo3 · error
Could not find _sysconfigdata*.py in {}
Error message
Could not find _sysconfigdata*.py in {} What it means
Error from find_sysconfigdata during cross-compilation configuration: the PYO3_CROSS_LIB_DIR directory was searched but contained no file matching _sysconfigdata*.py, so the target interpreter's configuration cannot be read and cross-compile settings cannot be derived.
Source
Thrown at pyo3-build-config/src/impl_.rs:2047
fn starts_with(entry: &DirEntry, pat: &str) -> bool {
let name = entry.file_name();
name.to_string_lossy().starts_with(pat)
}
fn ends_with(entry: &DirEntry, pat: &str) -> bool {
let name = entry.file_name();
name.to_string_lossy().ends_with(pat)
}
/// Finds the sysconfigdata file when the target Python library directory is set.
///
/// Returns `None` if the library directory is not available, and a runtime error
/// when no or multiple sysconfigdata files are found.
fn find_sysconfigdata(cross: &CrossCompileConfig) -> Result<Option<PathBuf>> {
let mut sysconfig_paths = find_all_sysconfigdata(cross)?;
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);
}
View on GitHub (pinned to ac9b6899d3)
Solutions
- Ensure the cross lib dir contains the target interpreter's _sysconfigdata module (usually in its lib directory)
- Point PYO3_CROSS_LIB_DIR at the correct sysroot/lib folder for the target
- Alternatively set PYO3_CROSS_PYTHON_VERSION (and optionally PYO3_CROSS_PYTHON_IMPLEMENTATION) instead of supplying a lib dir
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at pyo3-build-config/src/impl_.rs:2047 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/82d1ead274e51e35.
Report an issue: GitHub.