错误:找不到 'setup.cfg' 文件,无法进行 '<包名>' 的旧式可编辑安装
ERROR: File 'setup.cfg' not found for legacy editable install of '<package>'
ID: pip/error-installing-packages-in-editable-mode-with-pyproject-toml-and-no-setup-cfg
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| pip 21.3-23.2 | active | — | — | — |
| Python 3.8-3.12 | active | — | — | — |
| setuptools 64+ | active | — | — | — |
| flit-core 3.8+ | active | — | — | — |
根因分析
Pip 正在尝试对一个具有 pyproject.toml 但没有 setup.cfg 的项目进行旧式可编辑安装 (pip install -e .),而构建后端不支持 PEP 660 可编辑安装。
English
Pip is attempting a legacy editable install (pip install -e .) for a project that has a pyproject.toml but no setup.cfg, and the build backend doesn't support PEP 660 editable installs.
官方文档
https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs解决方案
-
pip install -e . --no-build-isolation
-
pip install --editable . --config-settings editable_mode=strict
-
pip install -e . --no-use-pep517 && pip install --no-deps --force-reinstall --no-build-isolation -e .
无效尝试
常见但无效的做法:
-
Creating an empty setup.cfg file in the project root
95% 失败
Pip requires a properly formatted setup.cfg with package metadata; an empty file does not satisfy the legacy editable install mechanism.
-
Downgrading pip to version 21.2 or earlier
80% 失败
Older pip versions may not support pyproject.toml-based builds properly, leading to other errors.
-
Using --no-use-pep517 flag
90% 失败
This flag forces legacy setup.py install, which still requires setup.cfg for editable mode.