python
module_error
ai_generated
true
AttributeError: 模块'setuptools'没有属性'setup'
AttributeError: module 'setuptools' has no attribute 'setup'
ID: python/pip-egg-info-attribute-error
80%修复率
85%置信度
0证据数
2024-03-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
导入语句错误或模块名被遮蔽。通常由本地文件名为'setuptools.py'或在部分安装后错误导入setuptools引起。
English
Incorrect import statement or shadowed module name. Often caused by a local file named 'setuptools.py' or importing setuptools incorrectly after a partial installation.
解决方案
-
90% 成功率
Check for and rename local setuptools.py, then run: python -c "import setuptools; print(setuptools.__file__)"
-
80% 成功率
Explicitly import: import setuptools; setuptools.setup()
无效尝试
常见但无效的做法:
-
70% 失败
If a local setuptools.py file exists in the working directory, it shadows the real package regardless of reinstallation.
-
50% 失败
Wildcard imports can hide the actual attribute if the module namespace is polluted or if there's a circular import.