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

Question:

version pip 21.2.4
python 3.6

The command:

pip install -r  requirements.txt

The content of my requirements.txt:

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

The command is failing with this error

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('"'"'rn'"'"', '"'"'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
Asked By: vamsi

||

Answers:

It looks like setuptools>=58 breaks support for use_2to3:

setuptools changelog for v58

So you should update setuptools to setuptools<58 or avoid using packages with use_2to3 in the setup parameters.

I was having the same problem, pip==19.3.1

Answered By: nnseva

Upgrading MongoEngine to >= 0.20 would also fix the problem as Python2 support (hence use_2to3) was dropped in 0.20

Answered By: bagerard

I install setuptools==58It worked for me. pip install setuptools==58. The error coming from setuptools==69 that previously run on my device. and Finally saved me setuptools version 58 for this error.

Answered By: Md Jewele Islam

"pip install setuptools==58" worked for me. The setuptools version was 59 when I upgraded ubuntu to 22.04 and its python 3.10. I started a clean virtual environment for an existings django project. It had just two packages:

`pip list
Package Version


pip 22.0.2
setuptools 59.6.0`

Then I downgrade the setuptools to 58 as pip install setuptools==58.0.0. After that the pip install -r requirements.txt has not such error above.

Answered By: Anand Pusarla

This worked for me.

pip install --upgrade pip setuptools==57.5.0 
Answered By: Jonny

I’m working on Windows 11 and these solutions didn’t work. I installed pybluez2 instead. Your python version >= 3.9 on Windows.

pip install pybluez2
Answered By: Jacob Isaman
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.