{"record":{"id":"44e9ce20054bd099","repo":"tracel-ai/burn","slug":"no-cxx11-abi-returned-by-python-output","errorCode":null,"errorMessage":"no cxx11 abi returned by python {output:?}","messagePattern":"no cxx11 abi returned by python (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-tch/build.rs","lineNumber":91,"sourceCode":"                .output()\n                .expect(\"error running python interpreter\");\n            let mut cxx11_abi = None;\n            for line in String::from_utf8_lossy(&output.stdout).lines() {\n                match line.strip_prefix(\"LIBTORCH_CXX11: \") {\n                    Some(\"True\") => cxx11_abi = Some(\"1\".to_owned()),\n                    Some(\"False\") => cxx11_abi = Some(\"0\".to_owned()),\n                    _ => {}\n                }\n                if let Some(path) = line.strip_prefix(\"LIBTORCH_INCLUDE: \") {\n                    libtorch_include_dirs.push(PathBuf::from(path))\n                }\n                if let Some(path) = line.strip_prefix(\"LIBTORCH_LIB: \") {\n                    libtorch_lib_dir = Some(PathBuf::from(path))\n                }\n            }\n            match cxx11_abi {\n                Some(cxx11_abi) => cxx11_abi,\n                None => panic!(\"no cxx11 abi returned by python {output:?}\"),\n            }\n        } else {\n            let libtorch = Self::prepare_libtorch_dir(os)?;\n            let includes = env_var_rerun(\"LIBTORCH_INCLUDE\")\n                .map(PathBuf::from)\n                .unwrap_or_else(|_| libtorch.clone());\n            let lib = env_var_rerun(\"LIBTORCH_LIB\")\n                .map(PathBuf::from)\n                .unwrap_or_else(|_| libtorch.clone());\n            libtorch_include_dirs.push(includes.join(\"include\"));\n            libtorch_include_dirs.push(includes.join(\"include/torch/csrc/api/include\"));\n            if lib.ends_with(\"lib\") {\n                // DEP_TCH_LIBTORCH_LIB might already point to /lib\n                libtorch_lib_dir = Some(lib);\n            } else {\n                libtorch_lib_dir = Some(lib.join(\"lib\"));\n            }\n            env_var_rerun(\"LIBTORCH_CXX11_ABI\").unwrap_or_else(|_| \"1\".to_owned())","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-tch/build.rs#L73-L109","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (build shell)\nLIBTORCH_USE_PYTORCH=1 cargo build --features tch   # 'python' has no torch -> panic\n// after\nsource ~/miniconda3/envs/ml/bin/activate            # env where torch is installed\nLIBTORCH_USE_PYTORCH=1 cargo build --features tch","handlingStrategy":"validation","validationCode":"# run before cargo build with LIBTORCH_USE_PYTORCH=1\nimport torch, sys\ntry:\n    import torch\n    print(torch.__version__)\nexcept ImportError:\n    sys.exit(\"active python has no torch; activate the right env or set LIBTORCH manually\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","build-script","python","libtorch","environment"],"backgroundTag":"libtorch-python-probe-failed","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}