Reputation: 11
While uploading my python flask app to Heroku I got the following error:
ERROR: Could not find a version that satisfies the requirement dataclasses==0.8 (from -r /tmp/build_d980c139/requirements.txt (line 4)) (from versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
remote: ERROR: No matching distribution found for dataclasses==0.8 (from -r /tmp/build_d980c139/requirements.txt (line 4))
remote: ! Push rejected, failed to compile Python app.
Upvotes: 1
Views: 1560
Reputation: 73
Heroku installs the latest python version for your app. Currently I'm assuming it is installing python version 3.9.6. But from python 3.8.0 and onwards the dataclasses==0.8 is pre-built there. this external dataclasses library only exists from 0.1 - 0.6 version (which is showing in the error message) and has probably stopped upgrading as it exists in the pre-built now. Since it is not finding that particular 0.8 version, so it is throwing that not found error.
Now to solve the problem, There can be two ways- The easy way is to remove dataclasses==0.8 from the requirement.txt and upload it.
Another way is to keep the dataclasses==0.8 in the requirement.txt and add another txt file called 'runtime.txt' in the same root directory where your requirement.txt is. And this line -Python {yourspecifiedversion}
. this will tell Heroku which python version to install. You can select a python version that will match properly with all of your external libraries. but you will need to add 'dataclasses==0.8' if the python version is less 3.8.0
Specifying a python runtime on Heroku is in this link - Specifying a Python Runtime
Upvotes: 6