# AttributeError: 模块'setuptools'没有属性'setup'

- **ID:** `python/pip-egg-info-attribute-error`
- **领域:** python
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

导入语句错误或模块名被遮蔽。通常由本地文件名为'setuptools.py'或在部分安装后错误导入setuptools引起。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Check for and rename local setuptools.py, then run: python -c "import setuptools; print(setuptools.__file__)"
   ```
2. **** (80% 成功率)
   ```
   Explicitly import: import setuptools; setuptools.setup()
   ```

## 无效尝试

- **** — If a local setuptools.py file exists in the working directory, it shadows the real package regardless of reinstallation. (70% 失败率)
- **** — Wildcard imports can hide the actual attribute if the module namespace is polluted or if there's a circular import. (50% 失败率)
