python install_error ai_generated true

error: command 'gcc' failed with exit code 1 ... building 'mypkg._ext' extension gcc -pthread -B /opt/conda/compiler_compat -Wl,--sysroot=/ -Wsign-compare ... mypkg/_ext.c:10:10: fatal error: Python.h: No such file or directory

ID: python/setuptools-command-error-build-ext

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2024-06-27First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

The Python development headers (Python.h) are not installed, so setuptools cannot compile a C extension during the build step.

generic

中文

未安装 Python 开发头文件(Python.h),因此 setuptools 在构建步骤中无法编译 C 扩展。

Workarounds

  1. 97% success
    On Debian/Ubuntu: sudo apt-get install python3-dev; on RHEL: sudo dnf install python3-devel; then retry pip install.
  2. 90% success
    Run pip install --only-binary=:all: mypkg to force wheel usage.

Dead Ends

Common approaches that don't work:

  1. 92% fail

    The failure is a missing system header, not an outdated setuptools.

  2. 90% fail

    Does not provide Python.h.

  3. 85% fail

    The header does not exist at that path without installing python3-dev.