tracel-ai/burn · error
no cxx11 abi returned by python {output:?}
Error message
no cxx11 abi returned by python {output:?} What it means
When LIBTORCH_USE_PYTORCH is set, burn-tch's build script queries the active Python interpreter to locate the installed PyTorch/libtorch and to determine the C++11 ABI flag. If the python probe output contains no `LIBTORCH_LIB: ` line (so no library dir) and/or no cxx11 ABI answer, the script panics. Essentially: python found PyTorch but didn't report the metadata the build expects.
Source
Thrown at crates/burn-tch/build.rs:91
.output()
.expect("error running python interpreter");
let mut cxx11_abi = None;
for line in String::from_utf8_lossy(&output.stdout).lines() {
match line.strip_prefix("LIBTORCH_CXX11: ") {
Some("True") => cxx11_abi = Some("1".to_owned()),
Some("False") => cxx11_abi = Some("0".to_owned()),
_ => {}
}
if let Some(path) = line.strip_prefix("LIBTORCH_INCLUDE: ") {
libtorch_include_dirs.push(PathBuf::from(path))
}
if let Some(path) = line.strip_prefix("LIBTORCH_LIB: ") {
libtorch_lib_dir = Some(PathBuf::from(path))
}
}
match cxx11_abi {
Some(cxx11_abi) => cxx11_abi,
None => panic!("no cxx11 abi returned by python {output:?}"),
}
} else {
let libtorch = Self::prepare_libtorch_dir(os)?;
let includes = env_var_rerun("LIBTORCH_INCLUDE")
.map(PathBuf::from)
.unwrap_or_else(|_| libtorch.clone());
let lib = env_var_rerun("LIBTORCH_LIB")
.map(PathBuf::from)
.unwrap_or_else(|_| libtorch.clone());
libtorch_include_dirs.push(includes.join("include"));
libtorch_include_dirs.push(includes.join("include/torch/csrc/api/include"));
if lib.ends_with("lib") {
// DEP_TCH_LIBTORCH_LIB might already point to /lib
libtorch_lib_dir = Some(lib);
} else {
libtorch_lib_dir = Some(lib.join("lib"));
}
env_var_rerun("LIBTORCH_CXX11_ABI").unwrap_or_else(|_| "1".to_owned())View on GitHub (pinned to d16f7ba2ed)
Solutions
- Activate/point to the Python env that has torch installed before building (e.g. `source venv/bin/activate` or set PYTHON_SYS_EXECUTABLE).
- Verify `python -c "import torch; print(torch.__version__)"` works in the build shell; install torch if missing.
- Pin a PyTorch version compatible with your tch/burn-tch versions (check tch's supported libtorch versions) and rebuild.
- Alternatively skip the python probe: set LIBTORCH / LIBTORCH_LIB and LIBTORCH_INCLUDE env vars to a downloaded libtorch distribution.
Example fix
// before (build shell) LIBTORCH_USE_PYTORCH=1 cargo build --features tch # 'python' has no torch -> panic // after source ~/miniconda3/envs/ml/bin/activate # env where torch is installed LIBTORCH_USE_PYTORCH=1 cargo build --features tch
Defensive patterns
Strategy: validation
Validate before calling
# run before cargo build with LIBTORCH_USE_PYTORCH=1
import torch, sys
try:
import torch
print(torch.__version__)
except ImportError:
sys.exit("active python has no torch; activate the right env or set LIBTORCH manually") Prevention
- Activate the Python environment containing torch before building
- Verify `python -c 'import torch'` works in the exact build shell
- Pin PyTorch versions compatible with your tch crate version
- Or bypass the probe by setting LIBTORCH/LIBTORCH_INCLUDE to a libtorch download
When it happens
Trigger: Building with LIBTORCH_USE_PYTORCH=1 when `python` prints unexpected output — wrong interpreter on PATH without torch, a conda/venv mismatch, a torch version whose probe script output format differs, or pip-installed CPU/GPU torch layouts the probe can't parse.
Common situations: Multiple Python installs (system vs conda vs pyenv) so `python` isn't the one with torch installed; recently upgraded PyTorch to a version incompatible with the pinned tch crate; missing python3-torch distro package; CI image where torch is installed for a different interpreter.
Related errors
- error running python interpreter
- LibTorch is not supported as a remote-server backend (no Bac
- unsupported TARGET_OS '{os}'
- Unsupported dtype for `bool_from_data`
- Unsupported dtype for `int_from_data`: {:?}
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/44e9ce20054bd099.
Report an issue: GitHub.