I am stuck trying to deploy this Flask App through Heroku. I've researched multiple ways to go about it, but can't seem a way to find it to work. This is what I get when I push to git push heroku master
remote: -----> Building on the Heroku-20 stack
remote: -----> Python app detected
remote: ! Requested runtime (python-) is not available for this stack (heroku-20).
remote: ! Aborting. More info: https://devcenter.heroku.com/articles/python-support
remote: ! Push rejected, failed to compile Python app.
I've cleared & set up build pack and is currently:
=== wonders141 Buildpack URL
heroku/python
The runtime.txt contains:
python-3.9.1
I'm not sure why the error message doesn't define the python version, so I'm at a lost of how to go about this.
This may be a late answer, but you have to use a newline after python-3.9.6 in runtime.txt
Your python version is not supported on heroku stack 20 - and make sure your python version in runtime is in lower case - see below
I figured how to get past this. I had cleared everything in my requirements.txt and left only the packages I needed. Apparently a lot of unnecessary packages were included.
I had the same problem with Django and I just upgrade python version to One of the supported versions in heroku, then I modified the (runtime.txt) file with the new version python-3.10.7
then I run git's commands like :
git status
git add -A
git commit -m "with any name you want"
git push heroku main --force
Related
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 months ago.
Improve this question
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 :)
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.
I made a package.json and added:
Heroku buildpacks:set heroku/python
It still fails when deploying. This is a python app so I don't know what is happening.
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Node.js app detected
parse error: Invalid numeric literal at line 1, column 7
! Unable to parse package.json
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
For apps that do not have a buildpack explicitly set, Heroku tries to detect which buildpack to use in the following order:
Ruby
Node.js
Clojure
Python
...
Buildpack detection is based on the presence of certain files. In the case of the Node.js buildpack, it looks for a package.json in the root directory of the project. It looks like your app has such a file.
Your question isn't entirely clear, but I think you put this text inside your package.json:
Heroku buildpacks:set heroku/python
That is not valid, so the Node.js buildpack doesn't know what to do with it.
A package.json file is from the Node.js ecosystem, and it must have a specific set of keys and values. Unless your application also requires Node.js, you shouldn't have a package.json file at all. Assuming you don't need that file, delete it and commit its removal.
Your Python project will need one of the following:
requirements.txt
setup.py
Pipfile and Pipfile.lock
If you already have one of these, great. Just redeploy and Heroku should detect your app as a Python app.
If you don't have any of these, the easiest thing to do is to place an empty requirements.txt file in the root of your project. Make sure to commit it before deploying again.
If you wish to be explicit, you can run the command you tried to use before on the command line:
heroku buildpacks:set heroku/python
This shouldn't be necessary for a single-language app, though. Note that heroku is all lowercase.
I am trying to upload my website to Heroku and I can't get past the (git push heroku master) part. I am following the steps in "Python crash course". I have my python version in my runtime.txt but I keep getting the error
remote: -----> Using Python version specified in runtime.txt
remote: ! Requested runtime () is not available for this stack (heroku-20).
remote: ! Aborting. More info: https://devcenter.heroku.com/articles/python-support
My runtime.txt has python-3.9.9 in it.
I know python-3.9.9 is supported based on devcenter
Picture of devcenter supported runtimes:
Picture of my runtime code:
My runtime is in the root directory.
Picture of the error I am getting:
I cant push my website because of this and I can't figure it out. Does anyone know what is going on here?
Your runtime.txt does not contain what you think it does. The error says
Requested runtime () is not available for this stack (heroku-20)
The value in those parentheses shows what Heroku sees in your runtime.txt: it's seeing an empty string, not python-3.9.9.
The runtime.txt you show in your screenshot is modified (see the "⬤" in the tab). Save it, commit it, then deploy again.
Other similar issues with answers have not resolved my issue. My deployment method is GitHub and I've not run into an issue with pushing to the repo, however, nothing seems to be able to run. I did set the build pack to Python in the settings of my Heroku app.
For reference, this is my repo I'm using for deployment: https://github.com/EhabJames/MC-Bot-Disc
Full Error:
App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
! Push failed
I am trying to deploy new code at Heroku. The changes I made are simple, no changes to settings or requirements or anything fundamental.
However, when running git push, I get...
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-python.git
=====> Detected Framework: Python
-----> Installing requirements with pip
ImportError: No module named site
! Push rejected, failed to compile Multipack app.
! Push failed
Does anybody have a clue what may be going on here?
I found similar questions already posted, but no clear answer and the proposed solutions didn't work in this case.
Heroku support suggested so far:
$ heroku config:unset PYTHONPATH
$ heroku config:unset PYTHONHOME
Following this, the deployment was possible, but the application stopped working.
By adding those variables back, the application was online again, but deployment would again fail.
Looking for a Solution for two days now - I would appreciate any advice.
requirements.txt file is here.
In this case, the solution to the problem is to remove only the PYTHONHOME variable. The other variable is needed.
The reason was a change in heroku-buildpack-python.
More info here:
https://github.com/heroku/heroku-buildpack-python/issues/457