PyO3/pyo3 · error
Neither abi3 or abi3t features are enabled
Error message
Neither abi3 or abi3t features are enabled
What it means
pyo3's build config requires one of the `abi3` or `abi3t` (free-threaded stable ABI) cargo features to be enabled when a stable-ABI configuration is being derived. `default_stable_abi_config` is only reached when the build expects a stable ABI target, and finding neither feature enabled means the stable ABI request is inconsistent with the declared features, so the build fails immediately with this message.
Solutions
- Add `abi3` (or `abi3t` for free-threaded Python) to the pyo3 feature list in Cargo.toml
- If you do not want the stable ABI, remove whatever invokes the abi3 configuration path (e.g. abi3-pyXY features or PYO3 abi3-related env settings)
- Run `cargo tree -e features` to confirm the abi3 feature actually reaches pyo3, since features are unified across the dependency graph
Example fix
// before
pyo3 = { version = "0.22", features = ["extension-module"] }
// after
pyo3 = { version = "0.22", features = ["extension-module", "abi3-py38"] } Defensive patterns
Strategy: validation
Validate before calling
# Cargo.toml check before building // shell cargo tree -e features | grep -q 'pyo3 .*abi3' || echo 'abi3 feature missing: add features = ["abi3"] to pyo3'
Prevention
- Always declare abi3 via a versioned feature like abi3-py38 rather than hand-rolled config
- Run cargo tree -e features in CI to assert the abi3 feature reaches pyo3
- Do not selectively strip features from pyo3 in workspace member manifests
When it happens
Trigger: Enabling stable-ABI-related configuration (e.g. PYO3_USE_ABI3_FORWARD_COMPATIBILITY paths, cross-compilation config files, or pyo3-build-config internals that call default_stable_abi_config) without enabling the `abi3` or `abi3t` cargo feature on the pyo3 dependency.
Common situations: Developers toggle `features = ["abi3"]` off while leaving other abi3 settings in place; Cargo feature resolution strips `abi3` because another crate in the graph disabled it; hand-written build scripts or config-generation code call into pyo3-build-config expecting a stable ABI but never declare the feature.
Related errors
- cannot set a minimum Python version
- Cannot target an abi3t version below
- Invalid config that sets both target_abi and abi3.
- At least GraalPy version
- broken Python interpreter
AI-assisted analysis of PyO3/pyo3@ac9b6899d3 (2026-09-05).
Data as JSON: /api/errors/43b0750167451373.
Report an issue: GitHub.
Appendix: source
Thrown at pyo3-build-config/src/impl_.rs:2323
}
/// Generates "default" interpreter configuration when compiling stable ABI extensions
/// without a working Python interpreter.
///
/// `abi3_version` or `abi3t_version` specifies the minimum supported Stable ABI
/// CPython version and which stable ABI to target.
///
/// This should work for most CPython extension modules when compiling on
/// Windows, macOS and Linux.
///
/// Must be called from a PyO3 crate build script.
fn default_stable_abi_config(
host: &Triple,
abi3_version: Option<PythonVersion>,
abi3t_version: Option<PythonVersion>,
) -> Result<InterpreterConfig> {
if abi3_version.is_none() && abi3t_version.is_none() {
bail!("Neither abi3 or abi3t features are enabled")
}
let (stable_abi, version) = if let Some(version) = abi3_version {
(StableAbi::Abi3, version)
} else if let Some(version) = abi3t_version {
(StableAbi::Abi3t, version)
} else {
unreachable!();
};
if stable_abi == StableAbi::Abi3t && version < MINIMUM_SUPPORTED_VERSION_ABI3T {
bail!("Cannot target an abi3t version below {MINIMUM_SUPPORTED_VERSION_ABI3T}")
}
// FIXME: PyPy & GraalPy do not support the Stable ABI.
let target_abi = PythonAbiBuilder::new(PythonImplementation::CPython, version)
.stable_abi(stable_abi)
.finalize()?;
let builder = InterpreterConfigBuilder::new(PythonImplementation::CPython, version)View on GitHub (pinned to ac9b6899d3)