Heroku things my build pack is node.js when its python - python

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.

Related

Requested runtime (python-) is not available for this stack (heroku-20)

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

Heroku buildpack error while pushing

When i try to add my github repo Gitlink i get this error
! No default language could be detected for this app.
HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
See https://devcenter.heroku.com/articles/buildpacks
! Push failed
What is wrong???
Heroku knows that your app is a Python app by the existence of one of two files in the root of your application:
PipFile
requirements.txt
You should set up a requirements.txt or Pipfile in order to get your project work on Heroku. In addition, you will need Postgres as your deployment DB, if you need a db at all.
You can have a look for more at the docs or the getting started guide

Heroku not loading procfile

I've tried other peoples solutions to getting there procfile recognised and it's just not working for me. Really confused about how I can get heroku to recognize my Procfile! I've moved it around into different folders and whatnot but it just won't recognise it.
web: waitress-serve --port=$PORT alex1.wsgi:application
This is my code. It's sitting right next to my requirements.txt file which is getting picked up by heroku fine. using echo to create the file or even echo is not working.
https://github.com/Hewlbern/Videography-Website/tree/master/Alex1 <--- the github link that I'm trying to deploy to heroku from. Can see where i've placed it and etc if anyone can help!
Such sad, many mad.
EDIT
Put them at top of directory - still not working.
Here's the error log.
-----> Python app detected
! Warning: Your application is missing a Procfile. This file tells Heroku how to run your application.
! Learn more: https://devcenter.heroku.com/articles/procfile
-----> Installing requirements with pip
-----> $ python manage.py collectstatic --noinput
63 static files copied to '/tmp/build_b9ce82b65ae441b651c56911a7474859/Hewlbern-ConsultingPage-1720e65/djreact/static/root'.
-----> Discovering process types
Procfile declares types -> (none)
-----> Compressing...
Done: 64.3M
-----> Launching...
Released v19
https://consultingpage.herokuapp.com/ deployed to Heroku
In response to Mike's point below I went through his example I reached this point.
C:\Users\Holbinator\Desktop\Software Dev\Alexandria>git push heroku master fatal: 'heroku' does not appear to be a git repository fatal: Could not read from remote repository.
I then re-did Git Init in the root directory and then tried to load the code from Github.
This led to the same issue.
I'll put this in my edit. Thanks! I'm going to try and do your method now and work out why I couldn't in this instance.
EDIT TWO
Now realised I needed to delete a extra heroku app. Now loading the files using heroku cli. Have no received an error, unsure how to access error logs but will try and solve the issue now.
First point of my recommendation will be to put .idea directory in .gitignore file.
I've uploaded your application on heroku and as result -Procfile was added successfully.
Steps:
git add . in your root directory
git commit -m "init commit"
heroku create
git push heroku master
That's mine result, but you will probably see something similar to this :
Afterwards I've launched your application via heroku open command and received the 500 error.
Screenshot of logs
I hope this answer will be useful, also read about deploy on heroku
UPD: Please check if you using git init in your root directory of project

How can I get Heroku to detect buildpack?

I am trying to deploy my Pyramid app on Heroku and no matter what I do, I get the failed to detect buildpack error message after I try to push.
I have my requirements.txt from my pip freeze in there next to my setup.py as well as my Procfile and runapp.py. I am not using my master branch for Heroku and have been using
git push heroku local_branch:master
I have also tried to set the build pack manually by using
heroku buildpacks:set heroku/python
I also have tried using external buildpacks from github, but that also does not work. I must be missing something in my requirements.txt?
Also, I have read Pyramid's Docs on Heroku deployment as well as Heroku's. I have browsed here for help but all I can find is that to make sure requirements.txt is spelled correctly or just re-init my git.
Add a "requirements.txt" file to the root directory of your repository.

Why is my Flask app being detected as node.js on Heroku

I recently made some changes to the structure of my Flask app hosted on heroku and now heroku has decided to detect it as a Node.js app intead of a Python app. My application uses both python (Flask) for the backend api and javascript for the front end.
The changes I made included integrating npm and bower into my application to streamline the javascript development of the app.
The problem was introduced when I added a package.json to my root directory when I started using npm. It seems that the build detection script runs the nodejs detection first (here) which leads to this code: if [ -f $1/package.json ]; then
echo "Node.js" && exit 0 executing and Heroku thinks it's a nodejs app and exits before the python detection has a chance to run.
To solve this I had to manually tell Heroku that I wanted a python build using this command
heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-python.
The package.json file is causing Heroku to detect it as a node.js app. To prevent this, add the file name to a .slugignore file:
echo 'package.json' >> .slugignore
git add .slugignore
.slugignore is like .gitignore. It resides in the root directory of your repository and should contain a list of filenames and wildcard patterns. The matching files remain in your git repository, but are deleted from the slug after you push to Heroku. The deletion occurs before the buildpacks run, so the node.js buildpack won't find package.json and the app won't be misidentified as a node.js app.

Categories

Resources