Python pip install报错:setup command: use_2to3 is invalid解决方法

本文主要介绍Python中,使用pip install -r requirments.txt安装依赖包,报错error in mongoengine setup command: use_2to3 is invalid的解决方法。

报错信息:

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

安装命令:

pip install -r  requirments.txt
requirements.txt:
mongoengine==0.19.1
numpy==1.16.2
pylint
pandas==1.1.5
fawkes

原因及解决方法:

参考文档https://setuptools.pypa.io/en/latest/history.html#v58-0-0

从上面更新说明中,可以看出setuptools 58之后的版本不支持use_2to3 。所以需要将setuptools更新为58之前的版本。

或者也可以避免在设置参数中使用带有use_2to3的软件包。

推荐阅读
cjavapy编程之路首页