Home > other >  Heroku: "No Python version was specified", but runtime.txt exists
Heroku: "No Python version was specified", but runtime.txt exists

Time:10-27

I tried to deploy a python app to Heroku and I already have runtime.txt in the root of my directory but I don't know why Heroku can't find the "runtime.txt" file I specified and always gives this message:

Building on the Heroku-22 stack
-----> Determining which buildpack to use for this app
-----> Python app detected
-----> No Python version was specified. Using the buildpack default: python-3.10.8
       To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
-----> Installing python-3.10.8

Project file structure:

enter image description here

runtime.txt

python-3.7.15

I tried to find answers on Stack Overflow and find similar questions with no approved answers, but none wokred. I also tried to match my Python version with the Python runtime that is supported by Heroku.

CodePudding user response:

First, make sure you commit the runtime.txt file to git, otherwise, Heroku won't see it.

Also, Please see the supported versions for each stack. Your message says that you're using Stack 22, but Python 3.7.15 is only supported by Stack 18 and Stack 20. This can easily be solved by changing your stack with heroku stack:set heroku-20.

  • Related