I want to deploy my Django application to Heroku but I'm having trouble when I try to push. When I run git push heroku master it says:
Counting objects: 99, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (97/97), done.
Writing objects: 100% (99/99), 2.51 MiB | 98.00 KiB/s, done.
Total 99 (delta 22), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
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: Verifying deploy...
remote:
remote: ! Push rejected to mammadovs.
remote:
To https://git.heroku.com/mammadovs.git
I manually set my buildpack by running heroku buildpacks:set heroku/python.
You haven't declared any dependencies.
Decide if you want to use Pipenv or pip and add the appropriate dependency files to your repository. If you're new to this the simplest solution is likely to add a requirements.txt file containing
Django==2.2.3
to the root directory in your project. If you have other dependencies, add them too. Then commit the file and redeploy.
Defining your dependencies is important and you should always do it as a best practice. But it's required on Heroku. How else would Heroku know that it should install Django and whatever other libraries you use?
See https://devcenter.heroku.com/articles/getting-started-with-python#declare-app-dependencies
Related
This question already has answers here:
Heroku: No default language could be detected for this app for python even with runtime.txt
(3 answers)
heroku: no default language could be detected for this app
(15 answers)
Closed 8 days ago.
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.
I want to deploy a Django app on Heroku.
The development environment is wsl (debian), python3.9.0, and the virtual environment is "venv".
I referred here:
https://tutorial-extensions.djangogirls.org/ja/heroku/
It was completed before this code:
git push heroku master
Run git push heroku master,
then I got the following error:
(env) me#Ver:~/docker_heroku/djangogirls210307$ git push heroku master
Enumerating objects: 78, done.
Counting objects: 100% (78/78), done.
Delta compression using up to 4 threads
Compressing objects: 100% (64/64), done.
Writing objects: 100% (78/78), 25.08 KiB | 885.00 KiB/s, done.
Total 78 (delta 18), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
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: ad15f239126a3588a2ab6585b0ae52bfa25d9b7e
remote: !
remote: ! We have detected that you have triggered a build from source code with version ad15f239126a3588a2ab6585b0ae52bfa25d9b7e
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 django-210307.
remote:
To https://git.heroku.com/django-210307.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/django-210307.git'
I've run heroku create,
"djangogirls210307" has been created on heroku.
The output below is the information obtained with heroku info --app diangogirls210307
=== djangogirls210307
Auto Cert Mgmt: false
Dynos:
Git URL: https://git.heroku.com/djangogirls210307.git
Owner: mailme#gmail.com
Region: us
Repo Size: 0 B
Slug Size: 0 B
Stack: heroku-20
Web URL: https://djangogirls210307.herokuapp.com/
I also named the work directory "djangogirls210307" and worked with the following structure in it.
djangogirls210307/
|
|- env // by "venv", not "virtualenv""pipenv"
|-mysite // name of project
|-__init__.py
|-asgi.py
|-local_settings.py
|-urls.py
|-settings.py
|-wsgi.py
|-.gitignore
|-manage.py
|-Procfile
|-requirements.txt
|-runtime.txt
In the error,'django-210307.git' is displayed, but it is probably the remote repository created during practice today.
So, I would like to ask the following questions. Thank you for your cooperation.
I want to know the procedure until the deployment is completed successfully.
I want to know if it can be solved by changing the push destination.
However, I don't understand why the push destination was fixed with the git push heroku master command.
I want to know how to change and specify the push destination.
Please let me know if you don't mind if you use the wrong word in the question.
remote: -----> Building on the Heroku-20 stack
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
Set a buildpack manually:
heroku buildpacks:set heroku/python
I deployed my django app to heroku and its working well. When I change something in project on local files and want to push to heroku It always push all files and it takes time.
> git add templates/post/detail.html
> git commit -am "read more"
[master 153e38f] read more
2 files changed, 3 insertions(+), 3 deletions(-)
> git push heroku master
I use these commands. But it's deploying everything:
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 695 bytes | 695.00 KiB/s, done.
Total 7 (delta 5), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: ! Python has released a security update! Please consider upgrading to python-3.8.6
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> No change in requirements detected, installing from cache
remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: -----> $ python manage.py collectstatic --noinput
remote: 1392 static files copied to '/tmp/build_57ea00eb/staticfiles', 3734 post-processed.
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 280.5M
remote: -----> Launching...
remote: Released v15
remote: https://xxxxxxxxxx.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/xxxxxxxxxxxxxx.git
2d9ba8e..153e38f master -> master
The file that I changed around 1mb but it pushes 280mb. So what's the problem with it?
If you don't want to push your static file for every time then run this command :
heroku config:set DISABLE_COLLECTSTATIC=1
Enable static file for future:
heroku config:unset DISABLE_COLLECTSTATIC(for future use).
I am trying to run a python file on my heroku. I tried not setting a build pack as well as setting one and neither seems to work. The only files in my branch are a .py and the .git folder
Here is an error example:
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 590 bytes | 590.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
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 google-results.
remote:
https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-python
You need the following 2 files additionally in your git repo: runtime.txt and requirements.txt
runtime.txt is responsible for which Python version your program is going to use.
cat runtime.txt
python-3.7.2
supported runtime.txt version changes from time to time so check out https://devcenter.heroku.com/articles/python-runtimes
requirements.txt is needed to specify which libraries from https://pypi.org/ your project is depending on. Be sure to specify a version to avoid breakage.
You can get a list of your currently installed python libraries with the command: python -m pip freeze > requirements.txt
I have followed the instructions given under a tutorial (Link here). I have even included the runtime.txt file with the proper version of Python. I have searched everywhere but no solution seems to work. My GitHub project link for reference:
https://github.com/MithilRocks/chakri
The error message:
PS C:\Users\Mithil Bhoras\Documents\GitHub\chakri\chakri> git push heroku master
Counting objects: 90, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (80/80), done.
Writing objects: 100% (90/90), 8.78 MiB | 234.00 KiB/s, done.
Total 90 (delta 26), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
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 chakrilevels.
remote:
To https://git.heroku.com/chakrilevels.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/chakrilevels.git'
For future readers, the same solution as #hansTheFranz's comment, but from the command line:
At app creation: heroku create --buildpack heroku/python app_name
For an existing app: heroku buildpacks:set heroku/python
Also, the official Heroku Buildpack: Python documentation could help.
you can write requirements.txt by small litter to "r" not Requirements.txt
if you do not have requirements.txt file
you should make this file
in "cmd" can write this line
freeze > requirements.txt