使用 pip install 下载需求时出错(设置命令:use_2to3 无效。)

Error while downloading the requirements using pip install (setup command: use_2to3 is invalid.)

版本 pip 21.2.4 python3.6

命令:

pip install -r  requirements.txt

我的内容requirements.txt

mongoengine==0.19.1
numpy==1.16.2
pylint
pandas==1.1.5
fawkes

命令失败并出现此错误

ERROR: Command errored out with exit status 1:
     command: /Users/*/Desktop/ml/*/venv/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/setup.py'"'"'; __file__='"'"'/private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-pip-egg-info-97994d6e
         cwd: /private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/
    Complete output (1 lines):
    error in mongoengine setup command: use_2to3 is invalid.
    ----------------------------------------
WARNING: Discarding https://*/pypi/packages/mongoengine-0.19.1.tar.gz#md5=68e613009f6466239158821a102ac084 (from https://*/pypi/simple/mongoengine/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement mongoengine==0.19.1 (from versions: 0.15.0, 0.19.1)
ERROR: No matching distribution found for mongoengine==0.19.1

看起来 setuptools>=58 中断了对 use_2to3 的支持:

setuptools changelog for v58

因此您应该将 setuptools 更新为 setuptools<58 或避免在设置参数中使用带有 use_2to3 的软件包。

我遇到了同样的问题,pip==19.3.1

将 MongoEngine 升级到 >= 0.20 也可以解决此问题,因为 Python2 支持(因此 use_2to3)在 0.20

中被删除

我安装了 setuptools==58它对我有用。 pip install setuptools==58。来自 setuptools==69 的错误,之前 运行 在我的设备中。最后为我保存了这个错误的 setuptools 版本 58。

“pip install setuptools==58”对我有用。当我将 ubuntu 升级到 22.04 及其 python 3.10 时,setuptools 版本是 59。我为现有的 django 项目启动了一个干净的虚拟环境。它只有两个包裹:

`点列表 包版本


点子 22.0.2 安装工具 59.6.0`

然后我将 setuptools 降级为 58,因为 pip install setuptools==58.0.0。之后 pip install -r requirements.txt 就没有上面这样的错误了。