menu
To specify a Python runtime, add a runtime.txt file to your app’s root directory that declares the exact version number to use.
$ cat runtime.txt
python-3.12.4

Source: https://devcenter.heroku.com/articles/python-runtimes