{"record":{"id":"d62678584f134b8d","repo":"PyO3/pyo3","slug":"detected-multiple-possible-python-versions-please","errorCode":null,"errorMessage":"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\nsysconfigdata files found:","messagePattern":"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\nsysconfigdata files found:","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pyo3-build-config/src/impl_.rs","lineNumber":2063,"sourceCode":"    if sysconfig_paths.is_empty() {\n        if let Some(lib_dir) = cross.lib_dir.as_ref() {\n            bail!(\"Could not find _sysconfigdata*.py in {}\", lib_dir.display());\n        } else {\n            // Continue with the default configuration when PYO3_CROSS_LIB_DIR is not set.\n            return Ok(None);\n        }\n    } else if sysconfig_paths.len() > 1 {\n        let mut error_msg = String::from(\n            \"Detected multiple possible Python versions. Please set either the \\\n            PYO3_CROSS_PYTHON_VERSION variable to the wanted version or the \\\n            _PYTHON_SYSCONFIGDATA_NAME variable to the wanted sysconfigdata file name.\\n\\n\\\n            sysconfigdata files found:\",\n        );\n        for path in sysconfig_paths {\n            use std::fmt::Write;\n            write!(&mut error_msg, \"\\n\\t{}\", path.display()).unwrap();\n        }\n        bail!(\"{}\\n\", error_msg);\n    }\n\n    Ok(Some(sysconfig_paths.remove(0)))\n}\n\n/// Finds `_sysconfigdata*.py` files for detected Python interpreters.\n///\n/// From the python source for `_sysconfigdata*.py` is always going to be located at\n/// `build/lib.{PLATFORM}-{PY_MINOR_VERSION}` when built from source. The [exact line][1] is defined as:\n///\n/// ```py\n/// pybuilddir = 'build/lib.%s-%s' % (get_platform(), sys.version_info[:2])\n/// ```\n///\n/// Where get_platform returns a kebab-case formatted string containing the os, the architecture and\n/// possibly the os' kernel version (not the case on linux). However, when installed using a package\n/// manager, the `_sysconfigdata*.py` file is installed in the `${PREFIX}/lib/python3.Y/` directory.\n/// The `_sysconfigdata*.py` is generally in a sub-directory of the location of `libpython3.Y.so`.","sourceCodeStart":2045,"sourceCodeEnd":2081,"githubUrl":"https://github.com/PyO3/pyo3/blob/ac9b6899d348be4d54614d060dea53a645a12e36/pyo3-build-config/src/impl_.rs#L2045-L2081","documentation":"Error \"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\nsysconfigdata files found:\" thrown in PyO3/pyo3.","triggerScenarios":"Thrown at pyo3-build-config/src/impl_.rs:2063 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set PYO3_CROSS_PYTHON_VERSION to the exact wanted version, e.g. 3.12","Or set _PYTHON_SYSCONFIGDATA_NAME to the specific sysconfigdata file name (e.g. _sysconfigdata__linux_x86_64-linux-gnu.py)","Remove extraneous _sysconfigdata*.py files from the cross lib dir so only one candidate remains"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ac9b6899d348be4d54614d060dea53a645a12e36","analyzedAt":"2026-09-05T09:20:35.319Z","contentChangedAt":"2026-09-05T09:20:35.319Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}