Home > Software engineering >  Heroku pip install suddenly started to return an error: use_2to3 is invalid
Heroku pip install suddenly started to return an error: use_2to3 is invalid

Time:04-29

Heroku deploy started to return this error when trying to deploy a python app:

-----> Installing requirements with pip
       Collecting amqp==2.6.1
         Downloading amqp-2.6.1-py2.py3-none-any.whl (48 kB)
       Collecting anyjson==0.3.3
         Downloading anyjson-0.3.3.tar.gz (8.3 kB)
         Preparing metadata (setup.py): started
         Preparing metadata (setup.py): finished with status 'error'
         error: subprocess-exited-with-error
         
         × python setup.py egg_info did not run successfully.
         │ exit code: 1
         ╰─> [1 lines of output]
             error in anyjson setup command: use_2to3 is invalid.
             [end of output]
         
         note: This error originates from a subprocess, and is likely not a problem with pip.
       error: metadata-generation-failed
       
       × Encountered error while generating package metadata.
       ╰─> See above for output.
       
       note: This is an issue with the package mentioned above, not pip.
       hint: See above for details.
 !     Push rejected, failed to compile Python app.
 !     Push failed

There was no change in requirements.txt

CodePudding user response:

Heroku recently updated setuptools to 60.10.0 for python build pack

However, the setuptools upgrade also drops support for the deprecated use_2to3 feature, which may be used be a small number of legacy dependency versions. This change occurred in setuptools 58.0.0 (released 2021-09-04), which we have deliberately not updated to for as long as possible, in order to give any affected packages time to be fixed. However it's no longer viable to delay updating any longer, due to the pipenv compatibility issues.

The above pull request have some options to fix affected packages. In my case we didn't need anyjson anyway, removing it from requirements.txt fixed the problem

  • Related