App not compatible with buildpack: Django + Python - django

When I click deployed button on heroku, I get some error, I have deployed this project for a certain period of time, and this time I deployed this error:
-----> Building on the Heroku-18 stack
-----> Using buildpack: heroku/python
-----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
! Push failed
I already have requirnments.txt, runtime.txt, Procfile, I already added buildpack(heroku/python) in setting,
requirnments.txt
asgiref==3.2.10
beautifulsoup4==4.9.3
dj-database-url==0.5.0
dj-static==0.0.6
Django==3.1.1
gunicorn==20.0.4
Pillow==8.1.2
psycopg2-binary==2.8.6
pytz==2020.1
soupsieve==2.2.1
sqlparse==0.3.1
static3==0.7.0
runtime.txt
python-3.7.3
Procfile
web: gunicorn APP_NAME.wsgi --log-file -
Any help or explanation is welcome! Thank you.

Did you push the source code from your master or main branch?
I was having the same problem as you when I pumped into this: Deploy from local branch.
So if you are not in main branch, you can either switch to one, or use git push heroku your-current-branch:master.\

Related

Push rejected failed to compile python app

so i get this error when i try to deploy my master branch, i have set my requirements.txt, runtime.txt and Procfile but i still get this error
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> Using Python version specified in runtime.txt
! Requested runtime (python - 3.9.7) is not available for this stack (heroku-20).
! Aborting. More info: https://devcenter.heroku.com/articles/python-support
! Push rejected, failed to compile Python app.
! Push failed
my requirements.txt file
asgiref==3.4.1
dj-database-url==0.5.0
Django==3.2.7
django-heroku==0.3.1
gunicorn==20.1.0
Pillow==8.4.0
psycopg2==2.9.2
python-decouple==3.5
pytz==2021.3
sqlparse==0.4.2
whitenoise==5.3.0
please help
Your python version is not supported on heroku stack 20 as stated in the fifth line to check supported runtime see Heroku documentation
Heroku stack supports python-3.9.9 so specify that in your runtime.txt:
python-3.9.9
Have a look at the stack at https://devcenter.heroku.com/articles/heroku-20-stack

Why do I have errors deploying to heroku?

I am trying to push my app to heroku, I am following the tutorial from udemy - everything goes smooth as explained. Once I am at the last step - doing git push heroku master I get the following error in the console:
(flaskdeploy) C:\Users\dmitr\Desktop\jose\FLASK_heroku>git push heroku master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
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 mitya-test-app.
remote:
To https://git.heroku.com/mitya-test-app.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/mitya-test-app.git'
On a heroku site in the log area I have the following explanation of this error:
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Python app detected
-----> Installing python-3.6.13
-----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
-----> Installing SQLite3
-----> Installing requirements with pip
Collecting certifi==2020.12.5
Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
Processing /home/linux1/recipes/ci/click_1610990599742/work
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/linux1/recipes/ci/click_1610990599742/work'
! Push rejected, failed to compile Python app.
! Push failed
In my requirements.txt I have the following:
certifi==2020.12.5
click # file:///home/linux1/recipes/ci/click_1610990599742/work
Flask # file:///home/ktietz/src/ci/flask_1611932660458/work
gunicorn==20.0.4
itsdangerous # file:///home/ktietz/src/ci/itsdangerous_1611932585308/work
Jinja2 # file:///tmp/build/80754af9/jinja2_1612213139570/work
MarkupSafe # file:///C:/ci/markupsafe_1607027406824/work
Werkzeug # file:///home/ktietz/src/ci/werkzeug_1611932622770/work
wincertstore==0.2
This is, in fact, only a super simple test app that consists of app.py:
from flask import Flask
app = Flask(__name__)
#app.route('/')
def index():
return "THE SITE IS OK"
if __name__ == '__main__':
app.run()
and Procfile with this inside:
web: gunicorn app:app
I see a windows path in your requirements.txt. Not sure what you are trying to do there, but is there any reason that you install the packages from a local source?
So, I believe looking at the log from
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/linux1/recipes/ci/click_1610990599742/work
means that pip tries to install from a directory that does not exist. Your heroku dyno (container) tries to get the necessary dependency but failed when building. If you are not familiar with container, in essence it's an isolated barebone system that will build from the ground up, so it needs to install them (click, flask, etc.)
tl;dr heroku wants install from local, failed. Try changing requirements.txt e.g.
certifi==2020.12.5
click
Flask
gunicorn==20.0.4
itsdangerous
Jinja2
MarkupSafe
Werkzeug
wincertstore==0.2
to force pip to install from outside source (i.e. pypi).
i think the problem is in requirement.txt
remove
click # file:///home/linux1/recipes/ci/click_1610990599742/work
Flask # file:///home/ktietz/src/ci/flask_1611932660458/work
itsdangerous # file:///home/ktietz/src/ci/itsdangerous_1611932585308/work
Jinja2 # file:///tmp/build/80754af9/jinja2_1612213139570/work
MarkupSafe # file:///C:/ci/markupsafe_1607027406824/work
Werkzeug # file:///home/ktietz/src/ci/werkzeug_1611932622770/work
and replace with
Flask==1.1.2
because the packages is not find by heroku. heroku will pull packages from requiremts.txt from pypi

Django Heroku deployment - ! [remote rejected] master -> master (pre-receive hook declined)

There are a few posts with this particular issue however I've tried about five or six different suggestions from those posts and have had no luck.
When trying
git push heroku master
I get the following error:
(env) PS C:\Users\Shaun\Desktop\DjangoBlog\src> git push heroku master
Total 0 (delta 0), 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 murmuring-dusk-96030.
remote:
To https://git.heroku.com/murmuring-dusk-96030.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/murmuring-dusk-96030.git'
From the build log on the Heroku website:
-----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
! Push failed
I have a simple static website running Django 2.2.3 as back end. I've been developing in a virtual environment on my local machine and have the following project structure shown blow, where src/ was what I renamed the folder created by the django-admin startproject command.
I'd like to deploy my site on Heroku so I've signed up, installed Git and the Heroku CLI. In my terminal I've logged in to Heroku and initialized my Git repository in this top level root (src/). I've added a Procfile which contains the following:
web: gunicorn blog.wsgi --log-file -
I have the following in my runtime.txt file. I'm actually running 3.7.3 in my virtual environment but I've tried both ways:
python-3.6.1
To settings I added:
import django_heroku
MIDDLEWARE = [
# added this:
'whitenoise.middleware.WhiteNoiseMiddleware',
]
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
# Add configuration for static files storage using whitenoise
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
django_heroku.settings(locals())
My requirements.txt contains all packages I'm using and psycopg2, whitenoise and gunicorn, django-heroku.
I'm not sure what I'm doing wrong exactly, any help would be appreciated.
Your requirements.txt, along with your Procfile and runtime.txt, must be in the top-level root directory of your project.
Move them there, commit that change, and deploy again, e.g.
cd $PROJECT_ROOT
git mv src/requirements.txt .
git mv src/Procfile .
git mv src/runtime.txt .
git commit -m 'Move requirements.txt and Heroku files to root'
git push heroku master

Fail to push to Heroku: /app/.heroku/python/bin/pip:No such file or directory

I am trying to push a Django project to Heroku, but it keeps telling me that the following:
/app/.heroku/python/bin/pip: No such file or directory
The complete error message is shown below. How can I address this issue? Do I need to first install pip on Heroku?
Counting objects: 451, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (383/383), done.
Writing objects: 100% (451/451), 1.07 MiB | 349.00 KiB/s, done.
Total 451 (delta 87), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.5.1
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote: /app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51
/bin/steps/pip-install: line 5: /app/.heroku/python/bin/pip: No such file or directory
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to rocky-tor-70537.
remote:
To https://git.heroku.com/rocky-tor-70537.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/rocky-tor-70537.git'
My requirements.txt file is empty, as shown below.
# this is for Heroku and other servers.
# Locally, you should install requirements_base.txt
-r requirements_server.txt
My requirements_server.txt is as follows:
-r requirements_base.txt
# packages that are unnecessary on Windows/Mac local dev environments, or don't install properly
psycopg2>=2.5.1
My requirements_base.txt is as follows:
appdirs==1.4.3
asgi-redis==0.14.1
asgiref==0.14.0
autobahn==0.16.0
Babel==2.3.4
boto==2.42.0
channels==0.17.3
colorama==0.3.7
contextlib2==0.5.4
coverage==4.2
daphne==0.14.3
dj-database-url==0.4.1
Django==1.8.8
django-countries==4.0
django-easymoney==0.7.1
django-floppyforms==1.7.0
django-idmap==0.4.1
django-vanilla-views==1.0.4
djangorestframework==3.4.6
honcho==0.7.1
huey==1.2.0
IPy==0.83
mock==2.0.0
msgpack-python==0.4.8
otree-core==1.2.8
otree-save-the-change==1.1.3
packaging==16.8
pbr==1.10.0
py==1.4.31
pyparsing==2.2.0
pytest==2.9.2
pytest-django==3.0.0
python-redis-lock==3.2.0
pytz==2016.6.1
raven==5.25.0
redis==2.10.5
requests==2.11.1
schema==0.6.2
six==1.10.0
Twisted==16.2.0
txaio==2.5.1
unicodecsv==0.14.1
whitenoise==3.2.1
ws4py==0.3.5
XlsxWriter==0.9.3
zope.interface==4.2.0
I ran into this issue recently and was able to adjust it by changing the python version in the runtime.txt.
Changing to
python-3.5.2
But based off your requirements that you have listed, it seems like you are never getting to the requirements_base.txt.
In your requirements_server.txt file, change it so that:
-r requirements_base.txt
is listed there.
I simply had two typos in my runtime.txt
Make sure it says python-3.6.1 and not Python-3.6.1 or python 3.6.1
The error message is pretty bad. May this post save someone 30 minutes.
Looks like Heroku now supports only 3.6.1 and 2.7.13 Python versions.
https://devcenter.heroku.com/articles/python-runtimes#supported-python-runtimes
If you are using the default heroku buildpack I would guess that the requirements.txt file in your project folder is missing.
I had the same problem on Ubuntu 16.04 and after manually installing Heroku CLI, using
wget https://cli-assets.heroku.com/branches/stable/heroku-REPLACE_ME_OS-REPLACE_ME_ARCH.tar.gz -O heroku.tar.gz
mkdir -p /usr/local/lib
tar -xvzf heroku.tar.gz -C /usr/local/lib
/usr/local/lib/heroku/install
it worked like a charm.
In the folder I have 4 files. One is python script, second is procfile (no extension) with content web: gunicorn skripta1:app. Third is requirements.txt with:
appdirs==1.4.3
bokeh==0.12.5
click==6.7
Flask==0.12.2
gunicorn==19.7.1
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
numpy==1.12.1
packaging==16.8
pandas==0.20.1
pandas-datareader==0.4.0
pyparsing==2.2.0
python-dateutil==2.6.0
pytz==2017.2
PyYAML==3.12
requests==2.14.2
requests-file==1.4.2
requests-ftp==0.3.1
six==1.10.0
tornado==4.5.1
Werkzeug==0.12.2
And fourth is runtime.txt with python-3.5.2
According to Heroku documentation, the only two officially supported python runtimes are 2.7.13, and 3.6.1.
I recently had the same issue with oTree deployment in heroku, but as soon as I changed runtime.txt to python-3.6.1 everything went smoothly.
Oh dear - I removed a blank line in my requirements/production.txt in order to try and change the line number and everything started working (or rather on to my next completely different error)
I ran into this same problem on Windows trying to deploy a Python app to Heroku. Turns out it was a file encoding problem. Depending on how you create Procfile, requirements.txt and runtime.txt your encoding may vary.
Assuming you're running Windows, use PowerShell. Get the following PowerShell Function and paste it in to your PowerShell console. Using this, you can check your file encoding:
get-fileencoding requirements.txt
If it comes back anything besides ascii that's probably the issue. In my case, my three files were all unicode. I just did this to force them to ASCII:
'python-3.6.1' | out-file -en ascii runtime.txt
You can also use an editor and then save the file using ASCII encoding.
Once I made this change to my Procfile, requirements.txt and runtime.txt I was able to successfully deploy to Heroku.
I was switching from app engine to heroku and had a setup.cfg file in the root directory with following content:
[install]
prefix=
It caused this issues while deployment. After removing everything went well.

First push django in heroku

I'm trying to push my django app in heroku and I've followed all the instructions in the tutorial of heroku's page, but when i try to do the push i get this:
christian#christian-R480-R431-R481:~/Documentos/heroku/Portafolio6$ sudo git push heroku master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 542 bytes, done.
Total 5 (delta 0), reused 0 (delta 0)
! Push rejected, no Cedar-supported app detected
To git#heroku.com:mysterious-thicket-1865.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:mysterious-thicket-1865.git'
christian#christian-R480-R431-R481:~/Documentos/heroku/Portafolio6$
I dont know why this happens. Do I have to do the push in the django project or when i have the virtualenv folder?
Do you have a valid requirements.txt file? This file is needed by Heroku to pip install the relevant python packages that your app uses.
To auto generate this file, just run the following code:
pip freeze > requirements.txt
The requirements.txt file should reside at the top most level, adjacent to the app.
The 'Step 3 - Heroku Best Practices' section at http://www.deploydjango.com/django_project_structure/ will give you more info.
Check that you have the requirements.txt, Procfile and runtime.txt files in your directory.
To generate requirements.txt, activate your virtualenv and freeze the installed packages:
workon my_project
pip freeze > requirements.txt
Your Procfile is responsible for telling the heroku system how to run your app (and most likely is what is missing in this instance). Here is a sample:
web: gunicorn my_project.wsgi -b 0.0.0.0:$PORT
Your runtime.txt file is responsible for determining which version of python to run:
python-2.7.4
Ensure that all three files exist (technically runtime.txt is optional, but it's a good idea), are commited and then try your push again.