python install_error ai_generated true

错误:子进程退出并报错 × python setup.py egg_info 未能成功运行。 │ 退出码:1

error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [12 lines of output]

ID: python/pip-install-error-subprocess-exited-with-error

其他格式: JSON · Markdown 中文 · English
80%修复率
88%置信度
0证据数
2024-03-12首次发现

版本兼容性

版本状态引入弃用备注
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

根因分析

pip 尝试通过旧的 setup.py egg_info 路径从源码构建包,构建脚本失败——通常是缺少系统构建依赖(编译器、头文件)、setup.py 损坏,或 setuptools 版本不兼容。

English

pip is trying to build a package from source using the legacy setup.py egg_info path, and the build script fails — usually missing system build dependencies (compilers, headers), a broken setup.py, or incompatible setuptools version.

generic

解决方案

  1. 82% 成功率
    pip install --only-binary=:all: <package>
    # or force a wheel for a specific platform
    pip install <package> --only-binary=:all: --platform manylinux2014_x86_64 --python-version 311 --implementation cp --abi cp311
  2. 78% 成功率
    # Debian/Ubuntu
    sudo apt-get install -y build-essential python3-dev libffi-dev
    # macOS
    xcode-select --install
    # then
    pip install --no-build-isolation <package>
  3. 90% 成功率
    pip install -v <package> 2>&1 | tee pip.log
    grep -A40 'error:' pip.log

无效尝试

常见但无效的做法:

  1. 85% 失败

    Cache is not the cause; the build subprocess still fails identically because the underlying compiler/header issue remains.

  2. 60% 失败

    Upgrading build tools helps only if the failure is due to outdated setuptools; missing C headers or a broken setup.py still fails.