我面临着一个已经在很多论坛、github 问题、堆栈溢出问题等中进行过详细讨论的问题。
仅举几例:
anyjson 设置命令出错:use_2to3 无效 suds-jurko 设置命令出错:use_2to3 无效 ibm_db 设置命令中出现错误:use_2to3 无效 simpleeval安装问题:使用_2to3无效 https://github.com/liftoff/pyminifier/issues/132 https://github.com/Thibauth/python-pushover/issues/42 https://github.com/odoo/odoo/issues/76144
对我来说,安装或降级 setuptools 到低于
setuptools<58.0
的版本似乎无法解决问题。
为了测试它,我使用 python3.7.9 创建一个虚拟环境
(venv) ➜ headache git:(superbranch) ✗ python --version
Python 3.7.9
(venv) ➜ headache git:(superversion) ✗ pip --version
pip 23.1.2 from /local/venv/lib/python3.7/site-packages/pip (python 3.7)
有问题的库是
vatnumber==1.2
,不,我无法更改该版本,因此我需要在不更改该依赖项的版本的情况下解决构建问题。
我的设置工具是:
(venv) ➜ headache git:(superversion) ✗ pip show setuptools
Name: setuptools
Version: 57.5.0
Summary: Easily download, build, install, upgrade, and uninstall Python packages
Home-page: https://github.com/pypa/setuptools
Author: Python Packaging Authority
Author-email: [email protected]
License: UNKNOWN
Location: /local/venv/lib/python3.7/site-packages
Requires:
Required-by:
为了完整性,这是错误
Downloading vatnumber-1.2.tar.gz (19 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
error in vatnumber setup command: use_2to3 is invalid.
[end of output]
使用
-vvv
运行相同的命令显示,在虚拟环境中时,会启动 pip
子进程,并且 setuptools
正在升级到满足内部 vatnumber
要求的版本,但它会忽略已安装的设置工具.
Running command pip subprocess to install build dependencies
Using pip 23.1.2 from /local/venv/lib/python3.7/site-packages/pip (python 3.7)
Collecting setuptools>=40.8.0
Using cached setuptools-67.7.2-py3-none-any.whl (1.1 MB)
Collecting wheel
Using cached wheel-0.40.0-py3-none-any.whl (64 kB)
Installing collected packages: wheel, setuptools
Creating /tmp/pip-build-env-bswyzp5y/overlay/bin
changing mode of /tmp/pip-build-env-bswyzp5y/overlay/bin/wheel to 775
Successfully installed setuptools-67.7.2 wheel-0.40.0
Installing build dependencies ... done
Running command Getting requirements to build wheel
error in vatnumber setup command: use_2to3 is invalid.```
我想问,是否有人偶然发现了类似的情况,或者是否有人可以提供任何帮助,以便更深入地研究问题并解决构建问题。在这种情况下,我无法固定
setuptools
版本。
我遇到了同样的错误(除了anyjson包)。我可以通过运行
pip install wheel
来修复它。老实说,我不太确定它为什么有效,但我认为这与通过直接构建轮子“获取构建轮子的要求未成功运行”有关。
这里的解决方案是安装库
--no-build-isolation
例如,
pip3 install setuptools==57.5.0 wheel
pip3 install -no-build-isolation --no-cache-dir -U vatnumber==1.2
构建隔离是 PEP518 的一项功能,其中构建过程不会在本地环境中查找构建时依赖项(例如 setuptools)。 --no-build-isolation 标志禁用此功能,以便使用本地 setuptools 安装进行构建。