Error in anyjson setup command: use_2to3 is invalid

Question:

#25 3.990   × python setup.py egg_info did not run successfully.
#25 3.990   │ exit code: 1
#25 3.990   ╰─> [1 lines of output]
#25 3.990       error in anyjson setup command: use_2to3 is invalid.
#25 3.990       [end of output]

This is a common error which the most common solution to is to downgrade setuptools to below version 58. This was not working for me. I tried installing python3-anyjson but this didn’t work either. I’m at a complete loss.. any advice or help is much appreciated.

If it matters: this application is legacy spaghetti and I am trying to polish it up for a migration. There’s no documentation of any kind.

The requirements.txt is as follows:

cachetools>=2.0.0,<4
certifi==2018.10.15
Flask-Caching
Flask-Compress
Flask==2.0.3
cffi==1.2.1
diskcache
earthengine-api==0.1.239
gevent==21.12.0
google-auth>=1.17.2
google-api-python-client==1.12.1
gunicorn==20.1.0
httplib2.system-ca-certs-locater
httplib2==0.9.2
oauth2client==2.0.1
pyasn1-modules==0.2.1
redis
requests==2.18.0
werkzeug==2.1.2
six==1.13.0
pyasn1==0.4.1
Jinja2==3.1.1
itsdangerous==2.0.1


Flask-Celery-Helper
Flask-JWT==0.2.0
Flask-Limiter
Flask-Mail
Flask-Migrate
Flask-Restless==0.16.0
Flask-SQLAlchemy
Flask-Script
Flask-Testing
Flask==2.0.3
Pillow<=6.2.2
Shapely
beautifulsoup4
boto
celery==3.1.23
geopy
gevent==21.12.0
numpy<1.17
oauth2client==2.0.1
passlib
psycopg2
pyproj<2
python-dateutil==2.4.1
scipy
Asked By: Richard McCormick

||

Answers:

Installing setuptools 57.5.0 solved the same issue for me.

pip install setuptools~=57.5.0
Answered By: desiguel

Downgrading setuptools worked for me

pip install "setuptools<58.0.0"

And then

pip install django-celery
Answered By: Kiran Modini

Installing a version of setuptools lower than 58.0.0 solved the issue.

pip install "setuptools<58.0.0" 

It happens because Use_2to3 has been removed from setuptools >=58.0.0 versions

Answered By: gigi