python
module_error
ai_generated
true
ERROR: File "setup.py", line 1, in <module> from setuptools import setup ModuleNotFoundError: No module named 'setuptools'
ID: python/pip-legacy-editable-develop-error
80%Fix Rate
87%Confidence
0Evidence
2024-02-14First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
The build environment (often an isolated PEP 517 env or a fresh venv) does not have setuptools installed, and the project's setup.py imports it unconditionally.
generic中文
构建环境(通常是隔离的 PEP 517 环境或全新的 venv)未安装 setuptools,而项目的 setup.py 无条件导入它。
Workarounds
-
95% success
Add a build-system table to pyproject.toml: [build-system]\nrequires = ["setuptools>=61", "wheel"]\nbuild-backend = "setuptools.build_meta"
-
85% success
Install with build isolation disabled: pip install --no-build-isolation .
-
90% success
Install setuptools in the active venv then run pip install -e . --no-build-isolation
Dead Ends
Common approaches that don't work:
-
90% fail
setup.py must be evaluated before install_requires is processed, so the import fails first.
-
85% fail
pip build isolation creates a fresh env for the build, so the host setuptools is not visible.
-
70% fail
If the project still needs setup.py for dynamic metadata, removing it breaks the build entirely.