-1

The problem For context:

  • I have deployed an app with Heroku
  • I have Python 3.9.2 running locally in VS Code vs Python 3.10.8 running on a Heroku machine

I am currently encountering the problems as mentioned on this thread.

I have found the solution to my problem seems to be switching python interpreters and copying my various packages to that location.

However, there is little documentation on how to do this in Heroku.

Any assistance is really appreciated :)

What I've tried Given the lack of documentation on the above, I've tried the following...

I found that the Heroku deployment was running on Python 3.10.8 runtime, whereas my local machine had been running 3.9.2.

I then added a runtime.txt in the root of the app's directory in Github that specified to use 3.9.2, but when I try and redeploy the build failed.

Following the Heroku logs, this leads me to:

-----> Building on the Heroku-22 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> Using Python version specified in runtime.txt
 !     Requested runtime 'cat runtime.txt
python-3.9.2' is not available for this stack (heroku-22).
 !     For supported versions, see: https://devcenter.heroku.com/articles/python-support
 !     Push rejected, failed to compile Python app.
 !     Push failed

I then realise from the logs, that the build package isn't of 3.9.2 isn't supported.

I've then downloaded python 3.11.0 on my local machine (which is supported, as mentioned here).

Deactivated the current virtual environment (using 3.9.2).

Created a new virtual environment.

Rerun the app locally and checked it works.

I've then added the changes to the git repo.

Then, I've tried to deploy on Heroku. I'm now getting:

-----> Building on the Heroku-22 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> Using Python version specified in runtime.txt
 !     Requested runtime 'cat runtime.txt
python-3.11.0' is not available for this stack (heroku-22).
 !     For supported versions, see: https://devcenter.heroku.com/articles/python-support
 !     Push rejected, failed to compile Python app.
 !     Push failed

I then navigate to the support documentation

I then try and follow the support guidance around 'Checking the buildpack version', as my version of Python is supported, as per the documentation.

I run the command against my CLI which checks which buildpack version I have. I get:

=== [appnamegoeshere] BuildPack URL
heroku/python

So, I have the 'heroku/python' buildpack.

Not sure where to go from here?

Any help is much appreciated :)

davidism
  • 121,510
  • 29
  • 395
  • 339
e-driver1
  • 45
  • 7
  • I know nothing about heroku, and this seems more like a server configuration question than programming. But, is this correct output? Looks corrupt to me. `Requested runtime 'cat runtime.txt python-3.9.2' is not available for this stack` What is "cat runtime.txt" doing in there? – miken32 Nov 03 '22 at 17:15
  • @miken32 you're right it probably is a server configuration issue. Given that I'm using python, and there seem to be issues with the packages I tagged python. WRT runtime.txt issue, I was following [this](https://devcenter.heroku.com/articles/python-runtimes) documentation. It says 'To specify a Python runtime, add a runtime.txt file to your app’s root directory that declares the exact version number to use'. Which is what I did in Github... – e-driver1 Nov 03 '22 at 17:25
  • You may want to read about ["why 'Can somebody help me?' is not an actual question"](https://meta.stackoverflow.com/a/284237/11107541). – starball Nov 03 '22 at 17:39
  • @e-driver1, the issue is what you put _in_ your `runtime.txt`, as described below. – ChrisGPT was on strike Nov 03 '22 at 19:15

1 Answers1

0

The documentation for selecting a runtime says:

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.10.8

The cat runtime part of that is a command that you can run on many systems (Linux, macOS, etc.) to print the contents of a file out. It should not be included in the file.

Your runtime.txt should just contain the appropriate python-x.y.z line. At the moment, on the Heroku-22 stack you can use Python 3.9:

python-3.9.15

Python 3.10:

python-3.10.8

Or Python 3.11:

python-3.11.0

The version you use on your local machine usually just needs to match the major and minor parts: your local Python 3.9.3 should be compatible with Heroku's 3.9.15.

Note that Heroku's list of supported Python versions is updated pretty frequently as new patch releases come out.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • thanks - fixed it. It now builds - which is a relief. :) However, the issue now is how to resolve the 'Exception with an error code: 0x38 (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND)' error. Which I can't follow [here](https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/1310#issuecomment-970342978), as described above... – e-driver1 Nov 03 '22 at 20:40