0

I am following a book called Django for beginners, and in their section for deploying to heroku, i am getting an error while trying to deploy. The project is working fine, and the website can be viewed. I have followed everything that was said and all the commands were working. I installed gunicorn, added a procfile, updated allowed_hosts, and then for deploying to heroku, i used git init and committed my changes. I logged into heroku, used the create command, then disabled collection of static pages. Everything was working fine, however when I ran

git push heroku main

There is also only one branch, which is main instead of master on github. Then, when I run the code, I get this error

Enumerating objects: 1095, done.
Counting objects: 100% (1095/1095), done.
Delta compression using up to 4 threads
Compressing objects: 100% (1082/1082), done.
Writing objects: 100% (1095/1095), 3.18 MiB | 1.92 MiB/s, done.
Total 1095 (delta 103), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-22 stack
remote: -----> Determining which buildpack to use for this app
remote:  !     No default language could be detected for this app.
remote:                         HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote:                         See https://devcenter.heroku.com/articles/buildpacks
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !       Push rejected to serene-inlet-76462.
remote: 
To https://git.heroku.com/serene-inlet-76462.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/serene-inlet-76462.git'

That wasnt working so I tried

git push heroku main --force
Enumerating objects: 1095, done.
Counting objects: 100% (1095/1095), done.
Delta compression using up to 4 threads
Compressing objects: 100% (1082/1082), done.
Writing objects: 100% (1095/1095), 3.18 MiB | 1.96 MiB/s, done.
Total 1095 (delta 103), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-22 stack
remote: -----> Determining which buildpack to use for this app
remote:  !     No default language could be detected for this app.
remote:                         HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote:                         See https://devcenter.heroku.com/articles/buildpacks
remote: 
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 54c2dd46f8b34ec5b0c780c5f397d79702a9cf15
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 54c2dd46f8b34ec5b0c780c5f397d79702a9cf15
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !       Push rejected to serene-inlet-76462.
remote: 
To https://git.heroku.com/serene-inlet-76462.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/serene-inlet-76462.git'

Because that wasn't working I also tried heroku buildpacks:set heroku/python but to no avail. Could really use some help.

NOTE: I am using a virtual environment to run all these commands.

  • This error is always caused by the same thing: Heroku's Python buildpack requires a `requirements.txt` file, a `Pipfile`, or a `setup.py` file to exist in the root directory of your project. If it does not find one of these files, it will not detect the project as a Python application. Even if you explicitly set the buildpack, you need to have one of these files in the root directory. – ChrisGPT was on strike Feb 11 '23 at 21:26

0 Answers0