56

When I run git push heroku master this is what I get:

C:\Users\Emanuele-PC\Desktop\project-mm-beta>git push heroku master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 505 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to project-mm-beta.
remote:
To https://git.heroku.com/project-mm-beta.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project-mm-beta.git'

The code I am trying to deploy is just one file (it's a test because it's my first time using Heroku) and it's written in Python. I have already set the buildpack (python) but it still doesn't work. How can I solve?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
BobbyJ
  • 639
  • 2
  • 8
  • 8
  • 14
    You need to include a `requirements.txt` file. It can be empty. https://devcenter.heroku.com/articles/python-runtimes#activation-1 – brennan Sep 08 '17 at 06:01
  • 5
    I did but I still get that error. – BobbyJ Sep 08 '17 at 06:07
  • Are any other errors shown if you run `heroku logs` – brennan Sep 08 '17 at 06:15
  • There is only this error: `2017-09-08T06:18:27.000000+00:00 app[api]: Build failed -- check your build logs` repeating at different times (only this type of error, no other one). But I think it's related to "App not compatible with buildpack". – BobbyJ Sep 08 '17 at 06:22
  • 1
    Maybe add a Procfile like https://stackoverflow.com/a/44854965/6085135 – brennan Sep 08 '17 at 06:28
  • Done but I still get that error, I don't know... – BobbyJ Sep 08 '17 at 06:41
  • Solved. I created a new app and I followed all the steps again (the previous one has US as country when I am in EU, I don't know if that could have been one of the reason. Thanks for the help anyway. – BobbyJ Sep 08 '17 at 06:47
  • Glad it's working, if it happens again maybe `git push -f heroku master` https://stackoverflow.com/questions/9794413/failed-to-push-some-refs-to-githeroku-com – brennan Sep 08 '17 at 06:52
  • I totally got same error when my branch `master` on github does not have any files (ex. package.json ...), so when i typed `git push heroku master`, it did not detect any files for building and pushing them (ex. can not find package.json). Therefore, after i pushed files to github, and typed `git push heroku master` success for release. – Huy Tower Oct 30 '18 at 03:00
  • Make sure that your buildpack is set correctly check out the docs for heroku https://devcenter.heroku.com/articles/buildpacks#officially-supported-buildpacks – Box and Cox Oct 11 '17 at 17:22
  • after you do pip freeze>requirements.txt, don't forget to git add . and git commit -m "added requirements.txt". Only then try again with git push heroku master – Tms91 Feb 26 '20 at 23:35

18 Answers18

56

The Heroku Python Support will be applied to applications only when the application has a Pipfile, setup.py, or requirements.txt in the root directory.

Visit the documentation to get detailed instructions.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Steev James
  • 2,396
  • 4
  • 18
  • 30
32

I just found out... It's quite a silly issue. Make sure the git repo is initialized within the project root folder. Suppose the project is a Django app and the project folder created by Django is my-project, the git repo needs to be initialized right within my-project for Heroku to work...

Ruifeng Ma
  • 2,399
  • 1
  • 22
  • 40
16

Add Pipfile and Procfile, and commit them. This solved it for me.

You can see the files I am speaking of on this Heroku documentation.

And here is a link to Heroku's Python buildpack on GitHub.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
amir_salar
  • 171
  • 1
  • 6
7

You can try doing:

  1. pip3 freeze > requirements.txt
  2. heroku buildpacks:set heroku/python
  3. git add .; git commit -m "add requirements.txt"; git push heroku master

Note: Make sure you're in your root directory of your Python project :)

Josh Arnold
  • 249
  • 4
  • 8
4

try add a file named requirement.txt and enter anything you need like django

Shi Bo-kai
  • 41
  • 1
3

Step 1) First setup the buildpack (programming-language )

For example : heroku buildpacks:set heroku/nodejs

Check for more info here : https://devcenter.heroku.com/articles/buildpacks

If the issue still exists, then follow next step

Step 2) git init and currently used directory is different, so this error is still thrown "App not compatible with buildpack:"

For example : git init command was used executed at :- C:/sample_folder/

But modules and package.json is under nested sub-folder :-

C:/sample_folder/nodejs_app/package.json

So move the files accordingly such that all the file are present under the same folder and then run

git push heroku master

--happy coding!

Parthasarathy S
  • 197
  • 1
  • 6
2

I was getting this error because I was making changes to a different branch. So I was working of a feature branch, then running git push heroku master. My changes had not been merged into my master branch, so thus the error. Once I merged in the Procfile to master I was able to push the changes up to heroku.

2

First file: requirements.txt

containing something like: gunicorn==19.7.1 or whatever the results of pip freeze > requirements.txt are.

Second file: Procfile

containing something like: web: gunicorn app:app or potentially blank. Note that app:app in this example is a reference to your python filename. It means that every time a web process is declared, and a dyno of this type is started, also run the command gunicorn app:app to start your web server.

Then git add . and git commit -m "added Procfile and requirements.txt".

Then run git push heroku master to push from your local master branch to the heroku remote.

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
  • 2
    It's great that you have answered the question, but can you please explain it more clearly? One way of making this more clearer is by formatting things as code. You can do this by using backticks `\`` – programmerRaj Jun 21 '20 at 13:31
2

I was having the same error because I was not committing the files, make sure you run the command git add . then git commit -m'message' after changing any file, and then you can run git push heroku master and also add the requirements.txt and Procfile correctly.

Tanmoy Bhowmick
  • 1,305
  • 15
  • 20
2

I had the same issue. Just make sure that you initialized the git repo inside the django project root. That way, your .git folder, .gitignore file, manage.py, requirements.txt, etc.. are on the same hierarchical level.

Emeruche
  • 31
  • 3
1

You can specify the buildpack for python by this method

CLI Installation

heroku buildpacks:set https://github.com/heroku/heroku-buildpack-python.git
Sumithran
  • 6,217
  • 4
  • 40
  • 54
1

Finally make sure you're not ignoring requirements.txt from your .gitignore, That was my problem.

Mwthreex
  • 913
  • 1
  • 11
  • 24
1

-> Make sure your requirements.txt & Procfile are in the root folder.

-> run following commands if you are not in the master branch already.

git checkout -b master
git add .
git commit -m "your commit message"
git push -u origin master
git push heroku master
K_Mohit
  • 528
  • 3
  • 17
0

Check if you did the following steps:

  1. Activate your virtual environment.

  2. Run on your command prompt:
    pip freeze>requirements.txt

  3. Add Procfile in your main app directory (the same where manage.py is);
    inside Procfile you should insert:
    web: gunicorn your_app_name.wsgi

Tms91
  • 3,456
  • 6
  • 40
  • 74
0

Well, same happened to me while I was creating a first-time Heroku app. Just add requirements.txt. It will work fine.

Shankar Ganesh Jayaraman
  • 1,401
  • 1
  • 16
  • 22
0

I just removed README.md from my GitHub repository which was connected to my Heroku app, and that worked for me!

Raza ul Mustafa
  • 104
  • 3
  • 8
0

Check whether you have written correct spelling of Procfile and requirements.txt, because they are case sensitive and In my case after changing the procfile to Procfile it started working properly.

Rjraj
  • 51
  • 4
-2

Run this command:

heroku buildpacks:set heroku/python

Also you can refer this document.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135