Updating specific files with git for django app on 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).

Related

remote: -----> App not compatible with buildpack: heroku error while hosting a discord bot

i wanted to host my discord bot on heroku
i have followed and youtube video till here
but i don't know what to do to fix this error
full
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 2.68 KiB | 2.68 MiB/s, done.
Total 6 (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: 0f11b1acbc6bdb39c6ea1fc83fa514db48551dfe
remote: !
remote: ! We have detected that you have triggered a build from source code with version 0f11b1acbc6bdb39c6ea1fc83fa514db48551dfe
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 bruh-bot-7869.
remote:
To https://git.heroku.com/bruh-bot-7869.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/bruh-bot-7869.git'
i have 2 files in the folder :-
main.py
rr.json
both are important
and in the Procfile :-
worker: python main.py
and requirements.txt :-
git+https://github.com/Rapptz/discord.py#rewrite
i have no idea what to do
please help!
i don't know what was the problem
but i uploaded my files to github and connected heroku github to heroku
and deploying
i was 100% doing it wrong in requirement.txt
when i used pip3 freeze (Marrows in the comments told me that) and added all that to requirements.txt and uploaded to github.
and after that deployed the bot it all worked fine . Thanks :)

Push rejected, failed to compile Python app in heroku (Python Crash Course)

I am working through the learning log project in Python Crash Course by Eric Matthes, specifically working on the learning log app. I am trying to deploy to heroku but get this error:
(ll_env) C:\Users\benpg\Documents\Coding\Python\learning_log>git push heroku master
Enumerating objects: 54, done.
Counting objects: 100% (54/54), done.
Delta compression using up to 4 threads
Compressing objects: 100% (46/46), done.
Writing objects: 100% (54/54), 16.54 KiB | 940.00 KiB/s, done.
Total 54 (delta 4), 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.7.3
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.7.4
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to pacific-refuge-12657.
remote:
To https://git.heroku.com/pacific-refuge-12657.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pacific-refuge-12657.git'
Tried everything here including the two other questions linked at the start, no luck.
Here's my requirements.txt:
Django==1.8.4
dj-database-url==0.3.0
dj-static==0.0.6
django-bootstrap3==6.2.2
gunicorn==19.3.0
static3==0.6.1
psycopg2>=2.6.1
Edit:
I am using django 2.2.4. My requirements.txt is the way it is because there is a note in the book saying 'if you're using Windows, make sure your version of requirements.txt matches the list shown here regardless of which packages you were able to install'. Why is this?
This is the first requirements.txt I had, autogenerated except for the last line. This one didn't work either, same error message:
dj-database-url==0.5.0
dj-static==0.0.6
Django==2.2.4
django-bootstrap3==11.1.0
gunicorn==19.9.0
pytz==2019.2
sqlparse==0.3.0
static3==0.7.0
psycopg2>=2.6.1
Just had the same issue, changing the Python version back do 3.7.3 fixed it. Was able to build python and execute.

Django app not compatible with buildpack https://.../python.tgz

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

Push rejected, failed to compile Python app - Python version error

I have used Heroku with PHP in the past but this is the first time I am using Heroku with Python and Flask. For start, I want to create a simple "Hello World" app and then upload a more complex program I have built. Therefore the project's folder contains the following:
One "Hello World" Python script (called Main.py):
from flask import Flask, render_template
app = Flask(__name__)
#app.route("/")
def index():
return render_template("index.html", message="Hello World")
if __name__ == "__main__":
app.run(debug=True)
A templates file with a index.html file (see above) inside it
One runtime.txt file:
python-3.6.5
One requirements.txt file:
Flask==1.0.1
(The project is originally located at /Users/User/PycharmProjects/Project_HelloWorld.)
However, when I enter git push heroku master at the terminal then I am getting the following error:
Counting objects: 85, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (82/82), done.
Writing objects: 100% (85/85), 5.01 MiB | 3.13 MiB/s, done.
Total 85 (delta 24), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: ! The latest version of Python 3 is python-3.6.5 (you are using {\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
remote: {\fonttbl\f0\fmodern\fcharset0 Courier;}
remote: {\colortbl;\red255\green255\blue255;\red43\green47\blue49;\red237\green237\blue244;}
remote: {\*\expandedcolortbl;;\cssrgb\c21961\c24314\c25098;\cssrgb\c94510\c94510\c96471;}
remote: \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
remote: \deftab720
remote: \pard\pardeftab720\partightenfactor0
remote:
remote: \f0\fs26 \cf2 \cb3 \expnd0\expndtw0\kerning0
remote: python-3.6.5}, which is unsupported).
remote: ! We recommend upgrading by specifying the latest version (python-3.6.5).
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing {\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
remote: {\fonttbl\f0\fmodern\fcharset0 Courier;}
remote: {\colortbl;\red255\green255\blue255;\red43\green47\blue49;\red237\green237\blue244;}
remote: {\*\expandedcolortbl;;\cssrgb\c21961\c24314\c25098;\cssrgb\c94510\c94510\c96471;}
remote: \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
remote: \deftab720
remote: \pard\pardeftab720\partightenfactor0
remote:
remote: \f0\fs26 \cf2 \cb3 \expnd0\expndtw0\kerning0
remote: python-3.6.5}
remote: ! Requested runtime ({\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
remote: {\fonttbl\f0\fmodern\fcharset0 Courier;}
remote: {\colortbl;\red255\green255\blue255;\red43\green47\blue49;\red237\green237\blue244;}
remote: {\*\expandedcolortbl;;\cssrgb\c21961\c24314\c25098;\cssrgb\c94510\c94510\c96471;}
remote: \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
remote: \deftab720
remote: \pard\pardeftab720\partightenfactor0
remote:
remote: \f0\fs26 \cf2 \cb3 \expnd0\expndtw0\kerning0
remote: python-3.6.5}) is not available for this stack (heroku-16).
remote: ! Aborting. More info: https://devcenter.heroku.com/articles/python-support
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to evening-sierra-26101.
remote:
To https://git.heroku.com/evening-sierra-26101.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/evening-sierra-26101.git'
How can I fix this error and properly run my app on Heroku?
Also when I am entering cat runtime.txt at the terminal for the runtime.txt above then I am getting the following (quite unexpected?) output:
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
{\fonttbl\f0\fmodern\fcharset0 Courier;}
{\colortbl;\red255\green255\blue255;\red43\green47\blue49;\red237\green237\blue244;}
{\*\expandedcolortbl;;\cssrgb\c21961\c24314\c25098;\cssrgb\c94510\c94510\c96471;}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\deftab720
\pard\pardeftab720\partightenfactor0
\f0\fs26 \cf2 \cb3 \expnd0\expndtw0\kerning0
python-3.6.5}%
I have firstly tried it with python-3.6.4 (instead of python-3.6.5) in the runtime.txt but I was getting the same error.
First I'd figure out how to run your app with gunicorn, as that's the most common deployment server for Flask apps. To run your app with gunicorn, you should be able to pip install gunicorn, then run from the root of your project: gunicorn my_file_name:app, where my_file_name == the name of the file that contains your Flask code above. E.g. if your Flask code is in a file named app.py, you'd run gunicorn app:app.
Once you can run the app with gunicorn, create a Procfile that specifies you want Heroku to run the server with gunicorn. Here's the contents of Procfile, which should be in the root of your project files (the same directory with requirements.txt):
web: gunicorn app:app
Then I'd update requirements.txt. Do a pip freeze | grep gunicorn to get your gunicorn version then add it to the requirements.txt file:
Flask==1.0.1
gunicorn==19.7.1
Finally, to resolve the immediate cause of your error above, I'd set runtime.txt to:
python-3.6.4
Then git push heroku master should be able to get you going...
If all else fails, here's a simple repository that has a barebones Flask app with Heroku deployment instructions in the README. It's deployed here: https://myapp-name-1.herokuapp.com/
So I found what it was going wrong and now my "Hello World" can run properly on Heroku.
The problem was the that even though I created anew the runtime.txt file and the requirements.txt for some reason the following "text" was inserted in them before the proper text:
\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
remote: {\fonttbl\f0\fmodern\fcharset0 Courier;}
remote: {\colortbl;\red255\green255\blue255;\red43\green47\blue49;\red237\green237\blue244;}
remote: {\*\expandedcolortbl;;\cssrgb\c21961\c24314\c25098;\cssrgb\c94510\c94510\c96471;}
remote: \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
remote: \deftab720
remote: \pard\pardeftab720\partightenfactor0
remote:
remote: \f0\fs26 \cf2 \cb3 \expnd0\expndtw0\kerning0
This was displayed at the error that I posted above when I was trying to do git push heroku master at my app and when I was entering cat runtime.txt. I finally spotted this by using a Hex editor. Therefore, Heroku was not only reading python-3.6.4 in my runtime.txt but also all this thing that I posted above before actually reading python-3.6.4. and this is the reason why I was getting an error.
As #Chris notes below at the comments, this unnecessary "text' was added (for some reason) because my .txt files were firstly saved (for some reason) as .txt.rtf and then I manually changed the extension to .txt without having in mind that something more was saved in them even thought I changed the extension. I deleted all this unnecessary "text" with my Hex editor and now everything is working fine.

Heroku Deployment Issue - Python version

I have been working on a Django project that I am trying to deploy to Heroku. I've followed a tutorial from Python Crash Course. When I enter git push heroku master, I get the following as a response:
Counting objects: 73, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (65/65), done.
Writing objects: 100% (73/73), 26.20 KiB | 0 bytes/s, done.
Total 73 (delta 8), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: ! The latest version of Python 3 is python-3.6.2 (you are using Python-2.7.12, which is unsupported).
remote: ! We recommend upgrading by specifying the latest version (python-3.6.2).
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing Python-2.7.12
remote: ! Requested runtime (Python-2.7.12) is not available for this stack (heroku-16).
remote: ! Aborting. More info: https://devcenter.heroku.com/articles/python-support
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to fathomless-scrubland-11916.
remote:
When I Python --version the cmd line returns 2.7.14 which is the most up-to-date version. I feel like this error is telling me I need to use Python3 but their site says that 2.7.14 is supported as well. My runtime.txt specifies 2.7.14.
Please try python-3.5.2 in runtime.txt
though it gives a warning it still works

Categories