Error in anyjson setup command: use_2to3 is invalid
Asked Answered
E

6

47
#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
Elspeth answered 28/5, 2022 at 9:29 Comment(2)
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.Elspeth
Does this answer your question? Error while downloading the requirements using pip install (setup command: use_2to3 is invalid.)Miru
R
108

Downgrading setuptools worked for me

pip install "setuptools<58.0.0"

And then

pip install django-celery
Renata answered 27/6, 2022 at 15:24 Comment(2)
why setuptools break change?Meagher
How does this solve the problem?Etymology
G
26

Installing setuptools 57.5.0 solved the same issue for me.

pip install setuptools~=57.5.0
Gilliangilliard answered 14/6, 2022 at 3:58 Comment(0)
C
8

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

pip install "setuptools<58.0.0" wheel

UPDATE (2023-11-02): anyjson was removed thanks to Brian Peterson and Aaron recommendation.

Cloche answered 30/5, 2023 at 15:57 Comment(4)
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( ThanksMagritte
couldn't install wheel due to the same use_2to3. Catch 22 here...Fives
I needed to include pip install wheel without anyjson, otherwise the latter blocked the former from finishingPersonalize
Any other answer is just to downgrade setuptools to 58 or below,but it doesn't work for me,until I saw that you added wheel here,but without anyjson,on Python 3.11,ThanksInstitutional
A
5

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

Allethrin answered 1/11, 2022 at 7:27 Comment(1)
pip install "setuptools<58.0.0" demjsonMeagher
C
1
pip install "setuptools<58.0.0" wheel --no-cache-dir

and after that

pip install django-celery

worked on my pc!

Calkins answered 1/11, 2023 at 23:47 Comment(2)
This answer does not add anything new to the currently available answers.Linlithgow
actually u right but can be found problem like me with cache. i try too all answer by the way didnt worked. when i try with --no-cache-dir worked so i want the help the others too.Calkins
M
0

I tried to run the recommended solutions and all failed for one reason or another. I was able to install anyjson like this:

  • Download tar.gz: curl -O https://files.pythonhosted.org/packages/c3/4d/d4089e1a3dd25b46bebdb55a992b0797cff657b4477bc32ce28038fdecbc/anyjson-0.3.3.tar.gz
  • Verify checksum: echo '37812d863c9ad3e35c0734c42e0bf0320ce8c3bed82cd20ad54cb34d158157ba anyjson-0.3.3.tar.gz' | sha256sum --check
  • Extract tar.gz: tar zxvf anyjson-0.3.3.tar.gz
  • Run 2to3 on the extracted dir: 2to3 -w anyjson-0.3.3
  • Pip install: pip install anyjson-0.3.3/
Money answered 12/7 at 12:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.