# 错误：文件 "setup.py"，第 1 行
    from setuptools import setup
ModuleNotFoundError：没有名为 'setuptools' 的模块

- **ID:** `python/pip-legacy-editable-develop-error`
- **领域:** python
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

构建环境（通常是隔离的 PEP 517 环境或全新的 venv）未安装 setuptools，而项目的 setup.py 无条件导入它。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Add a build-system table to pyproject.toml: [build-system]\nrequires = ["setuptools>=61", "wheel"]\nbuild-backend = "setuptools.build_meta"
   ```
2. **** (85% 成功率)
   ```
   Install with build isolation disabled: pip install --no-build-isolation .
   ```
3. **** (90% 成功率)
   ```
   Install setuptools in the active venv then run pip install -e . --no-build-isolation
   ```

## 无效尝试

- **** — setup.py must be evaluated before install_requires is processed, so the import fails first. (90% 失败率)
- **** — pip build isolation creates a fresh env for the build, so the host setuptools is not visible. (85% 失败率)
- **** — If the project still needs setup.py for dynamic metadata, removing it breaks the build entirely. (70% 失败率)
