SetuptoolsDeprecationWarning:setup.py install 已弃用。请使用 build 和 pip 及其他基于标准的工具。
SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
ID: python/setup-py-deprecated-invoke-setup
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
运行 `python setup.py install`(或 `python setup.py develop`)会调用 setuptools 已弃用的旧代码路径,官方推荐使用 PEP 517/518 构建前端(如 pip)。
English
Running `python setup.py install` (or `python setup.py develop`) invokes a legacy code path that setuptools has deprecated in favor of PEP 517/518 build frontends like pip.
解决方案
-
95% 成功率
Use pip: pip install . (pip invokes the PEP 517 build backend automatically)
-
93% 成功率
Build a wheel first: python -m build && pip install dist/*.whl
-
94% 成功率
For editable installs: pip install -e .
无效尝试
常见但无效的做法:
-
70% 失败
Suppresses the message but leaves the deprecated install path; future setuptools versions will remove it and break the build.
-
75% 失败
Pinning to an old setuptools breaks compatibility with modern pyproject.toml-based projects and other dependencies.
-
80% 失败
The --user flag does not change the deprecated code path; the warning persists and the install may still fail on modern Python.