28

After creating a repository in Heroku, I want to push my project from master branch to my heroku repo.

On my first try I got the following error message:

No default language could be detected for this app

After searching, I used the following command:

heroku buildpacks:set heroku/python

Now it gave me this error message:

App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz

So now I tried everything from the beginning and it gives me the following error:

Python app detected

Requested runtime ("python-3.7.1") is not available for this stack (heroku-18).

I am stuck here.

I do have a requirements.txt with all the requirements and a runtime.txt in the same folder as my manage.py file.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
haneulkim
  • 4,406
  • 9
  • 38
  • 80

5 Answers5

20

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.

Zahid Khan
  • 2,130
  • 2
  • 18
  • 31
  • This is only _partly_ correct. Yes, the `runtime.txt` needs to be formatted in a particular way. But the version to use is _not_ whatever you are using locally. Your local Python version should give the major and minor version, e.g. 3.8 in this example. But the actual version to use must be currently [supported by Heroku](https://devcenter.heroku.com/articles/python-support#supported-runtimes). At the moment, for Python 3.8, this would be `python-3.8.13`, and that is only available on the Heroku-18 and Heroku-20 stacks. – ChrisGPT was on strike Jun 29 '22 at 10:51
15

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.

Mihai Chelaru
  • 7,614
  • 14
  • 45
  • 51
  • I know it is possible to specify python version for virtual env in the beginning but can I change it? – haneulkim Feb 23 '19 at 03:36
  • What do you mean? Change the Python version to 3.7.1? – Mihai Chelaru Feb 23 '19 at 05:04
  • If you want to change the version of Python your virtual env is using you can take a look at [this question](https://stackoverflow.com/q/51915484/9374673) that I think describes your problem. – Mihai Chelaru Feb 23 '19 at 05:23
8

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

Ayaz Saiyed
  • 101
  • 1
  • 4
3

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.

KYHSGeekCode
  • 1,068
  • 2
  • 12
  • 30
3

In my case, my Runtime.txt was:

# Runtime.txt
python-3.8.5

Changed that to

python-3.10.7

Always check the dev centre to know the supported python versions. https://devcenter.heroku.com/articles/python-support#supported-runtimes

Dr.House
  • 784
  • 5
  • 11