# 错误：命令 '/usr/bin/gcc' 以退出码 1 失败

Cython.Compiler.Errors.CompileError: foo/_bar.pyx

- **ID:** `python/setuptools-cython-build-failure`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Cython 扩展编译失败，原因是缺少 C 头文件、编译器不兼容，或 Cython 版本与 .pyx 源码不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (80% 成功率)
   ```
   Install build prerequisites (e.g. `sudo apt-get install python3-dev libfoo-dev`) and pin a matching Cython: `pip install 'cython<3'` or `'cython>=3'` per the project's docs.
   ```
2. **** (85% 成功率)
   ```
   Prefer a prebuilt wheel: `pip install --only-binary=:all: <pkg>` to avoid compiling at all.
   ```

## 无效尝试

- **** — The compiler error is deterministic. (90% 失败率)
- **** — Optimization level is not the cause of a CompileError. (80% 失败率)
