Heroku/Django - No default language could be detected for this app - django

I am trying to deploy a Django app via Heroku for the first time.
When I run git push heroku master it returns this error:
remote: -----> Building on the Heroku-20 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: e6acd22b123b939729546f4f06f368a8855a4744
remote: !
remote: ! We have detected that you have triggered a build from source code with version e6acd22b123b939729546f4f06f368a8855a4744
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 vygrapp.
remote:
To https://git.heroku.com/vygrapp.git
! [remote rejected] master -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/vygrapp.git'
Following similar problems on SO I believe I have my file structure correctly configured - with git deployed from same place as my Procfile etc. I also have a requirements.txt file which I believe tells Heroku it's a python app - so I can't figure out why the buildpack isn't working.
Based on comments and feedback I moved all folders into root directory but receive the same error.

Heroku only looks for your Procfile, requirements.txt, and runtime.txt in the root directory of your project. Move them up a level so they're beside your .gitattributes.
That should let Heroku detect that this is a Python project and get past the current error.
But your project still won't run. Out of the box, Heroku will expect your Django project to also be in the root directory of your repository. You can probably get it to work from a subdirectory by playing around with the DJANGO_SETTINGS_MODULE environment variable and / or PYTHONPATH, but the easiest solution is to move your entire project up a directory.
I suggest you move everything from anybody/anybody1/ to anybody/, then delete the now empty anybody/anybody1/ directory.
Then commit, and redeploy.

Related

My flask Heroku attempt fails, i cannot pinpoint the problem

So I try to make a very simple test app to run with Heroku. Its my 3rd attempt from complete scratch. I have a single python file with very minimal content
from flask import Flask
app = Flask(__name__)
#app.route("/")
def test():
return "test"
if __name__ == '__main__':
app.run()
the file is named test.py, my directory also includes Procfile
web: gunicorn app:test
and requirments.txt
click==7.1.2
Flask==1.1.2
gunicorn==20.1.0
itsdangerous==1.1.0
Jinja2==2.11.3
MarkupSafe==1.1.1
Werkzeug==1.0.1
to top it off I have gitignore to ensure IDE files do not interfere,
.idea
.Heroku.iml
and runtime.txt
python-3.6.0
I then try to create an app using
heroku create <appname>
I then use second URL it returns in the command
git remote add heroku <url>
. Afterwards I do
git add .
git commit -m "some message"
git push heroku main
and get the following error.
To https://git.heroku.com/forgotten-fox.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/forgotten-fox.git'
I then try to do it using
git push heroku master
instead but no changes occur.
I also try to force it to use python build pack with
heroku buildpack:set heroku/python --app <appname>
as above the error it states that
Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
I don't know how to use git mostly, but my friend advised me to create remote repository and attach it to Heroku but I was not able to find how to do the attachment.
If anyone knows what causes that and / or how to solve it i would really appreciate if you share the knowledge.
Update:
Thanks for pointing out wrong name for requirements file, I've renamed it. I`ve also changed my Procfile to
web: gunicorn test:app
.
Sadly it doesn't resolve the issue (yes I did commit and push the changes made).
Here is the error messages:
for git push heroku master :
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 6 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (11/11), 1.66 KiB | 1.66 MiB/s, done.
Total 11 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 36fb38193ecf8aa8d27f79682de049be81cb8807
remote: !
remote: ! We have detected that you have triggered a build from source code with version 36fb38193ecf8aa8d27f79682de049be81cb8807
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 forgotten-fox.
remote:
To https://git.heroku.com/forgotten-fox.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/forgotten-fox.git'
and here for git heroku push main:
error: src refspec main does not match any
error: failed to push some refs to 'https://git.heroku.com/forgotten-fox.git'
.
Update
Ok, sorry everyone, I'm generally retarded. I missed the obvious part of error about build back, here it states the final fix I needed for my app to work.
the issue is that you have to use
web: gunicorn test:app
instead of
web: gunicorn app:test
the correct format is
gunicorn <filename>:<app object>

Push rejected by Heroku for the static file collection reason

When I'm trying to deploy a Django app to Heroku, encounter the identical problem as python - Collectstatic error while deploying Django app to Heroku - Stack Overflow
it starts to build, download and installs everything, but that's what I get when it comes to collecting static files:
$ git push heroku master
Counting objects: 5375, done.
Total 5375 (delta 1092), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing requirements with pip
remote:
...
remote:
remote: ! Error while running '$ python manage.py collectstatic --noinput'.
remote: See traceback above for details.
remote:
remote: You may need to update application code to resolve this error.
remote: Or, you can disable collectstatic for this application:
remote:
remote: $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote: https://devcenter.heroku.com/articles/django-assets
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy....
remote:
remote: ! Push rejected to fierce-cove-94300.
remote:
To https://git.heroku.com/fierce-cove-94300.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fierce-cove-94300.git'
I tried all its answers, but not helps.
Additional I tried Django and Static Assets | Heroku Dev Center to configure the setting and install whitenoise and commit changes.
The problem is not solved.
Disable auto collectstatic:
heroku config:set DISABLE_COLLECTSTATIC=1
Then push your project to heroku. After the deploy is done, manually collectstatic as below:
heroku run python manage.py collectstatic
If you still get errors, your static files config is probably the reason. Try making it simple, remove whitenoise and use a s3 bucket for example.

Outdated Pipfile.lock

I'm trying to deploy a large django project to heroku. I installed Heroku CLI, logged in, created an app and ran:
git push heroku master
I have a Pipfile and requirements.txt already set up. I added a runtime.txt to specify that I need python 2.7. This is also in the Pipfile. This is what I get from pushing to heroku:
Counting objects: 12159, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4853/4853), done.
Writing objects: 100% (12159/12159), 20.94 MiB | 1.82 MiB/s, done.
Total 12159 (delta 6859), reused 12036 (delta 6751)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.6.4
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 11.8.2…
remote: Your Pipfile.lock (3b2ba9) is out of date. Expected: (83a5b4).
remote: Aborting deploy.
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy....
remote:
remote: ! Push rejected to camp-infinity.
remote:
To https://git.heroku.com/camp-infinity.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/camp-infinity.git'
I'm not sure why it tries to install python 3, and it also doesn't like my Pipfile.lock file. I've tried deleting it and generating it again with pipenv install but that didn't change anything.
Make sure you have initialised your environment in Python 2.X with pipenv --two, then - given your code runs locally and all dependencies are specified in your Pipfile - run pipenv install and commit all changes including the Pipfile.lock to your local git repo (git add * && git commit -m "your message"). Finally push to heroku. Hope it now builds correctly.

Push rejected to herokuapp

I am trying to host my dango rest app on heroku. When i run
git push heroku master
I get the error log
remote: -----> Python app detected
remote: ! The latest version of Python 3 is python-3.6.4 (you
are using python-3.6.3, which is unsupported).
remote: ! We recommend upgrading by specifying the latest
version (python-3.6.4).
remote: Learn More:
https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing requirements with pip
remote: Collecting pkg-resources==0.0.0 (from -r
/tmp/build_76cc8692e5f28e80c394427df6e4d58b/requirements.txt (line
9))
remote: Could not find a version that satisfies the
requirement pkg-resources==0.0.0 (from -r /
tmp/build_76cc8692e5f28e80c394427df6e4d58b/requirements.txt (line 9))
(from versions: )
remote: No matching distribution found for pkg-
resources==0.0.0 (from -r
/tmp/build_76cc8692e5f28e80c394427df6e4d58b/requirements.txt (line
9))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to myapp.
remote:
To https://git.heroku.com/myapp.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to
'https://git.heroku.com/myapp.git'
The requirements.txt file is
dj-database-url==0.4.2
Django==1.11.2
django-rest-auth==0.9.2
djangorestframework==3.6.4
djangorestframework-jwt==1.11.0
gunicorn==19.7.1
olefile==0.44
Pillow==4.2.0
psycopg2==2.7.3
PyJWT==1.5.3
pytz==2017.2
six==1.11.0
whitenoise==3.3.1
push is rejected by heroku. please help.
Does your local requirements.txt match requirements.txt from master branch?
I had the same problem and finaly I realized that my master branch had that pkg-resources line in requirements.txt while my local copy hadn't. I deleted that line from requirements.txt, did git commit, git push and next time I tried to push my app to heroku I succeed.

How do I let Heroku Know I have a requirements.txt file

I am trying to deploy a Django app on to Heroku but when I type git push heroku master, I get this output:
Counting objects: 1213, done.
Compressing objects: 100% (1184/1184), done.
Writing objects: 100% (1213/1213), 4.36 MiB | 504.00 KiB/s, done.
Total 1213 (delta 449), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote:
remote: ! Push rejected, no Cedar-supported app detected
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to article-django.
remote:
To https://git.heroku.com/article-django.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/article-django.git'
I created a requirements.txt file, as advised in Heroku push rejected, no Cedar-supported app detected and I then typed in pip install -r requirements.txt before typing in git push heroku master again but I got the same output and so I need to know how to let Heroku know requirements.txt exists so I don't get this same error again.
I typed in git commit -m 'another commit' and I got this output:
Your branch is up-to-date with 'django/master'.
Untracked files:
procfile
requirements.txt
I then typed in these commands:
git add procfile
git add requirements.txt
I typed in git commit -m 'another commit' and then git push heroku master, which worked.
I'm not really sure, but maybe you miss to add a [Procfile].(https://devcenter.heroku.com/articles/procfile) This file is neccesary to declare which server/process is going to run the dyno.