PyO3/pyo3 · error
expected a bool (1/true/True or 0/false/False) for Py_ENABLE
Error message
expected a bool (1/true/True or 0/false/False) for Py_ENABLE_SHARED
What it means
Parsing error raised while InterpreterConfig is built from a sysconfigdata file (from_sysconfigdata). The Py_ENABLE_SHARED value read from the _sysconfigdata module was not one of the accepted boolean spellings (1/true/True/0/false/False), e.g. an empty string or localized/unusual token, so Rust's bool parser rejected it.
Source
Thrown at pyo3-build-config/src/impl_.rs:616
.ok_or(concat!($key, " not found in sysconfigdata file"))
};
}
macro_rules! parse_key {
($sysconfigdata:expr, $key:literal) => {
get_key!($sysconfigdata, $key)?
.parse()
.context(concat!("could not parse value of ", $key))
};
}
let soabi = get_key!(sysconfigdata, "SOABI")?;
let implementation = PythonImplementation::from_soabi(soabi)?;
let version = parse_key!(sysconfigdata, "VERSION")?;
let shared = match sysconfigdata.get_value("Py_ENABLE_SHARED") {
Some("1") | Some("true") | Some("True") => true,
Some("0") | Some("false") | Some("False") => false,
_ => bail!("expected a bool (1/true/True or 0/false/False) for Py_ENABLE_SHARED"),
};
// macOS framework packages use shared linking (PYTHONFRAMEWORK is the framework name, hence the empty check)
let framework = match sysconfigdata.get_value("PYTHONFRAMEWORK") {
Some(s) => !s.is_empty(),
_ => false,
};
let python_framework_prefix = sysconfigdata
.get_value("PYTHONFRAMEWORKPREFIX")
.map(str::to_string);
let lib_dir = get_key!(sysconfigdata, "LIBDIR").ok().map(str::to_string);
let gil_disabled = match sysconfigdata.get_value("Py_GIL_DISABLED") {
Some(value) => value == "1",
None => false,
};
let cygwin = soabi.ends_with("cygwin");
// purely descriptive of the interpreter in the sysconfigdata: PyO3's own
// build pipeline applies any abi3/abi3t cargo features to this config
// afterwards, in apply_build_envView on GitHub (pinned to ac9b6899d3)
Solutions
- Inspect the generated _sysconfigdata*.py and check the Py_ENABLE_SHARED entry for stray characters or an unexpected value
- Regenerate or point PYO3_CROSS_LIB_DIR/_PYTHON_SYSCONFIGDATA_NAME at a sysconfigdata file produced by the real target interpreter
- If cross-compiling, fix the toolchain/sysroot that produced the malformed file
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pyo3-build-config/src/impl_.rs:616 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/ebaa73693338bd96.
Report an issue: GitHub.