python module_error ai_generated true

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

AttributeError: module 'setuptools' has no attribute 'setup'

ID: python/pip-egg-info-attribute-error

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  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()

无效尝试

常见但无效的做法:

  1. 70% 失败

    If a local setuptools.py file exists in the working directory, it shadows the real package regardless of reinstallation.

  2. 50% 失败

    Wildcard imports can hide the actual attribute if the module namespace is polluted or if there's a circular import.