42
#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
vvvvv
  • 25,404
  • 19
  • 49
  • 81
Richard McCormick
  • 639
  • 1
  • 6
  • 12
  • Hello, thank you for responding. I have attempted setting setuptools to both version 58.0.0, and to the latest version. Both times to no success. – Richard McCormick May 31 '22 at 12:19
  • 1
    Does this answer your question? [Error while downloading the requirements using pip install (setup command: use\_2to3 is invalid.)](https://stackoverflow.com/questions/69100275/error-while-downloading-the-requirements-using-pip-install-setup-command-use-2) – Md Jewele Islam Sep 22 '22 at 05:53

4 Answers4

88

Downgrading setuptools worked for me

pip install "setuptools<58.0.0"

And then

pip install django-celery
Kiran Modini
  • 1,184
  • 8
  • 5
25

Installing setuptools 57.5.0 solved the same issue for me.

pip install setuptools~=57.5.0
desiguel
  • 505
  • 3
  • 10
4

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

gigi
  • 41
  • 3
1

If keep getting the error after downgrading setuptools, make sure to have installed wheel:

pip install "setuptools<58.0.0" wheel anyjson
iDevFS
  • 483
  • 1
  • 10
  • 16
  • I know it's an old topic but you need an upvote. The "wheel" part was the important bit I was missing. (I needed a really old troposphere version, but on python 3.11( Thanks – pmau Jul 12 '23 at 08:43
  • couldn't install wheel due to the same use_2to3. Catch 22 here... – Ovi Oprea Aug 12 '23 at 20:34