Error while pushing to Heroku: requested runtime is not available for this stack

Just upgrade the version in your runtime.txt file while pushing the code. List of official supported python version in stacks -

  • python-3.9.4
  • python-3.8.9
  • python-3.7.10
  • python-3.6.13

For more details check - https://devcenter.heroku.com/articles/python-support#supported-runtimes


Check your current version of Python:

C:\Python --version

Suppose:

Python 3.8.5

Now goto runtime.txt & specify your version of Python:

Syntax: python-<version>


Example:

python-3.8.5 is CORRECT.

Python-3.8.5 is INCORRECT.

Python 3.8.5 is INCORRECT.


Python 3.7.1 is not supported by Heroku, as per their documentation on supported runtimes. Change the Python version to 3.7.2 if you want Python 3.7, or 3.6.8 if you don't.

For information on specifying a runtime, see this page of the documentation. By default it uses 3.6.8 for Python, so if you want 3.7.2 you need to create a file called runtime.txt in the root directory of your app with python-3.7.2 written inside.


In my case, my Runtime.txt was:

# Runtime.txt
python-3.8.5

I removed #Runtime.txt line, and it worked! the app will assume you don't have a python version installed and install the correct one for you. Its an automatic process

Additionally, you should commit the changes before pushing.