Heroku App Not Compatible with Python Buildpack - python

I'm trying to deploy a Django/Python application that runs locally, but will not deploy to Heroku. When trying to deploy, I receive the error:
App not compatible with buildpack: https://codon-
buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
I've tried multiple solutions to this issue. Currently my build pack is set to the Python build pack. (heroic build packs returns heroku/python). I have a Procfile, requirements.txt, runtime.txt, and Pipfile.lock, all of which usually resolve this issue.
Procfile:
web: gunicorn foodForThought.wsgi:application --log-file -
requirements.txt:
Django==1.11.8
pytz==2017.3
runtime.txt:
python-3.6.0
Pipfile.lock:
[requires]
python_full_version = "3.6.0"
All the aforementioned files are located in my home directory, and I'm also working in a virtual environment. Why is this error occurring?

So here's what I've come up with. I was also stuck with this problem until I found this command.
heroku buildpacks:add --index 1 heroku/python
The trick is to add this buildpack before you commit to the Heroku git repo. You can follow the steps like so:
git add .
git commit -am "First Commit"
heroku git:remote -a yourapp
heroku buildpacks:add --index 1 heroku/python
git push heroku master
I found this through the Heroku docs!

Related

Flask app works locally, fails on heroku. Procfile and requirements.txt didn't do it..?

Started going a bit mad on this, hence first post.
I have yet to deploy an app public facing for others to use. They launch locally just fine..
How can I get this app to deploy on Heroku?
Here is my repository: https://github.com/codereyes-1/tesseract_flask_new
I wrote a python app in Flask that makes a call to google tesseract function. The app works locally but fails in Heroku.
There is no Flask build pack I can find. Some research returned "add a requirements.txt and Profile" but that didn't work.
Here is the build log from Heroku:
"
Building on the Heroku-20 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
"
¯\(ツ)/¯
This is what you will need to do to deploy your app to Heroku:
Login to heroku on your terminal ($ heroku login)
Ensure your application is in a git repository ($ git remote -v)
Create a Heroku application ($ heroku apps:create my_app-app)
Create Postgres database ($ heroku addons:add heroku-postgresql:hobby-dev)
Log errors to STDOUT
Set environment variables in Heroku ($ heroku config:set LOG_TO_STDOUT=1 # Add others if you have them)
Install gunicorn and psycopg2 ($ pip3 install gunicorn psycopg2)
Add Procfile to root directory and update it ($ touch Procfile)
Update your requirements.txt (pip3 freeze > requirements.txt)
Commit your changes ($ git commit -m '<your-commit-message>')
A remote Heroku repository ($ heroku git:remote -a <your-heroku-app-name>)
Push to Heroku ($ git push heroku master)
I was missing "web: gunicorn app:app" in my Procfile, I matched python to supported versions in runtime.txt.App launches correctly with these settings.
#BeppeC #Still_learning #Gitau Harrison Thank you all for your help. I got the app deployed, and I learned how to deploy my other apps as well. 🤜🏽🤛🏽

Couldn't find that process type (web) error on heroku

I'm trying to deploy a Django application to heroku, but i keep getting the following error when trying to scale my application
heroku ps:scale web=1
Error:
Scaling dynos... !
! Couldn't find that process type (web).
I don't understand what am i doing wrong here, my file is called Procfile, it is located at the root of my project, here is how i defined it:
Procfile
web: gunicorn myproject.wsgi --log-file -
follow this steps
remove existing build packs heroku buildpacks:clear
add them again using index option heroku buildpacks:add
add empty commit and push the changes
OR try this one step by step
remove your procfile
git commit
add a new procfile with the exact name "Procfile"
commit again
git push heroku master

heroku: no default language could be detected for this app

First time using Heroku. Trying to push. I have run the command:
heroku create --buildpack heroku/python
and it displayed
$ heroku create --buildpack heroku/python
Creating app... done, glacial-reef-7599
Setting buildpack to heroku/python... done
https://glacial-reef-7599.herokuapp.com/ | https://git.heroku.com/glacial-reef-7599.git
Stack trace:
$ git push heroku master
Counting objects: 129, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (124/124), done.
Writing objects: 100% (129/129), 69.06 KiB | 0 bytes/s, done.
Total 129 (delta 22), 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 pure-badlands-9125.
remote:
To https://git.heroku.com/pure-badlands-9125.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pure-badlands-9125.git'
I've gotta be missing something.
I have added a requirements.txt to my root directory. It looks like this:
.git
.idea
projectapp
projectname
rango
db.sqlite3
manage.py
populate_rango.py
requirements.txt
Quick Solution
Goto heroku dashboard (https://dashboard.heroku.com/)
go inside app/project
click setting
scroll down little bit and click add build pack
select your desired buildpack (in my case i have selected heroku/nodejs).
TLDR;
Actually what heroku does is, it tries to identify what project you are deploying by looking at files in your project, such as if your project have package.json file it understands it is a nodejs project, if your project have requirements.txt file it understands it is a python project and so on, see this document to see to know what languages you can run on a heroku server
as you know to run a specific project such as a nodejs project in a computer node runtime must be installed in that computer otherwise you can not nodejs app in the computer, what heroku does it runs each of your app in a different container, it means in one container it is only one app is running and of course that container have installed nodejs, so if a container runs only one app it doesnt make sense to install all other runtimes in the container so container have only one runtime in my case it is nodejs. they have ofcourse other type of containers such as one type for python and that container have installed python runtime(of a specific version) so if my app gets installed in python container it will not work because my app in in nodejs. for this very reason somehow we need to identify the type of app in beginning to choose correct container type, mostly heroku automatically detect it but if it is failed to detect you have to tell explicitly either by going to their dashboard settings or through runtime file in your project, and as you may have noticed you have do this only once.
For future references, you must ensure that you are pushing the branch with your code to heroku master.
If you branched from your master branch and all your code is on a, say, develop, push that to the heroku master.
So instead of:
git push heroku master
You would do something like:
git push heroku develop:master
This question has important details on this How to push different local Git branches to Heroku/master
When deploying using Docker, ensure to set the stack of the app to container, as shown in the docs:
heroku stack:set container
You need to create a runtime.txt file. On the command line, in the same folder as your requirements.txt file, enter echo "python-3.5.1" > runtime.txt. Of course, make sure to switch the 3.5.1 with whichever version of Python you are using.
I can't remember how I fixed this but looking at the Date Modified in my files after I posted this question I created two files:
runtime.txt (thanks rurp) which contains:
python-3.5.2
Procfile which contains:
web: gunicorn projectname.wsgi --log-file -
This is a Django project and projectname.wsgi leads to a wsgi.py located at
projectname/wsgi.py
This contains:
import os
import signal
import sys
import traceback
import time
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projectname.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
I had the same problem even after including runtime.txt. What worked was the inclusion of the requirements.txt
In my case I was in a sub git folder. When I looked at the root .git folder - the project indeed didn't had a package.json file - so heroku could not identify the webpack
I was running a django project and for me none of the solution above worked. So finally I gave up and went to the path thats mentioned in the error and it clearly stated that heroku needs either of the below file to detect a django project:
requirements.txt
setup.py
Pipfile
I than created a requirements.txt file by copying the contents of pip freeze in the root of the project and it worked correctly.
Faced this issue today and released I had named my requirements.txt as requirements.txt.txt(I literally named the file with .txt extension when it was already a text file), I also had a runtime.txt file with the content python-3.8.7.
Renaming the requirements.txt file correctly solved my issue.
I had 3 files in my root folder: code.py, requirements.txt and runtime.txt
Adding requirements.txt even as a blank text file did the trick for me, and I also ensured there was no build pack Heroku had added.
Heroku’s Python support extends to the latest stable release from the Python 2.x and Python 3.x series.
Today, this support extends to these specific runtimes:
python-2.7.13
python-3.6.1
try to change your python version in runtime.txt
Create Pipfile file in root folder and add python version and packages required for application. check sample file here
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
[packages]
django = "*"
gunicorn = "*"
django-heroku = "*"
[requires]
python_version = "3.6"
Also check Configuring Django Apps for Heroku
One more thing to note is to actually commit your changes to your git repo, before you can push them to Heroku.
You might have a requirements.txt setup locally, but if it's not committed to your repo, git push heroku master will not be able to locate it.
If you've tried some of the above answers and the problem still persists;
Ensure you are git "committing" in the right directory.
For instance, if your file structure is as follow:
/src
/...
manage.py
.gitignore
Pipfile/requirements.txt
Pipfile.lock
Procfile
runtime.txt
Ensure you're git adding, committing, pushing etc. from the root directory. Since we work mostly in the src/ or main_app_directory/ we tend to forget to change directory back to root before committing.
Hey guys so I have been stuck on this issue for the past two days and I found the solution to my problem. The first fix was renaming
"requirement.txt" to "requirements.txt"
then I removed the runtime.txt
cleared buildpacks using heroku cli set the buildpack to python
heroku buildpacks:set heroku/python
and Boom! it got uploaded an everything works now

Error while deploy my django website on heroku

I created a personal portfolio website using django and it also includes a blog. You can see the exact directory listing and source code in my github repository by clicking here
I have the procfile and the requirements.txt files as said in the heroku website and did the following in command prompt as directed by heroku :
$ heroku login
$ heroku git:clone -a appname
$ cd appname
$ git add .
$ git commit -am "make it better"
$ git push heroku master
Now I see the following error while deploying and the push fails :
Warning: Your application is missing a Procfile. This file tells Heroku how to run your application.
Yes there is a procfile in the directory though.
Please help me deploy this website in heroku.
Your file is called Procfile.txt. It should be called just Procfile.
It might be that you made a .txt file instead of a non-extension one or that you named it procfile and not Procfile. Heroku is sensitive about capitalisation.

Python cx_Oracle in Heroku

I'm struggling with this for one week. I'm trying to run a python flask app that connect with a remote Oracle Database using instant client version 11.2.0.3.0.
After a lot of problems, I ended using 3 buildpacks, two of them I need to customize and then I could install cx_Oracle in Heroku, but when I run the code I got the error:
import cx_Oracle
ImportError: libaio.so.1: cannot open shared object file: No such file or directory
Well, this error is very well documented, so I just needed to do:
$ apt-get install libaio1 libaio-dev
But the problem is how to run apt-get in a Heroku App? Using the third buildpack:
github.com/heroku/heroku-buildpack-apt
The other buildpacks:
github.com/Maethorin/oracle-heroku-buildpack
github.com/Maethorin/heroku-buildpack-python
After everything is configured, I runned a Heroku deploy and got the same error on execution. I could see in Heroku deploy log that heroku-buildpack-apt did its job but I got the same error in import cx_Oracle. Btw, just to be sure, I changed the forked python buildpack, that I'm using, to do pip uninstall cx_Oracle at each deploy so I can have a freshly compiled version of it.
At this point, the Great Internet was not able to help me anymore. Anywhere that I looked, I got the option to install libaio. I tried to search about using apt-get in Heroku App but everything points to heroku-buildpack-apt
I think the problem could be cx_Oracle cannot find the installed libaio and I setted a lot of Heroku App environment variables:
$ heroku config:set ORACLE_HOME=/app/vendor/oracle_instantclient/instantclient_11_2
$ heroku config:set LD_LIBRARY_PATH=/app/.apt/usr/lib/x86_64-linux-gnu:/app/vendor/oracle_instantclient/instantclient_11_2:/app/vendor/oracle_instantclient/instantclient_11_2/sdk:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib:/lib
$ heroku config:set LIBRARY_PATH=/app/.apt/usr/lib/x86_64-linux-gnu:/app/vendor/oracle_instantclient/instantclient_11_2:/app/vendor/oracle_instantclient/instantclient_11_2/sdk:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib:/lib
$ heroku config:set INCLUDE_PATH=/app/.apt/usr/include
$ heroku config:set PATH=/bin:/sbin:/usr/bin:/app/.apt/usr/bin
$ heroku config:set PKG_CONFIG_PATH=/app/.apt/usr/lib/x86_64-linux-gnu/pkgconfig
$ heroku config:set CPPPATH=/app/.apt/usr/include
$ heroku config:set CPATH=/app/.apt/usr/include
EDIT: I forgot to mention this:
When I run a heroku run ls -la /app/.apt/usr/lib/x86_64-linux-gnu where the libaio should be installed I got this:
drwx------ 3 u32473 dyno 4096 Dec 21 2013 .
drwx------ 3 u32473 dyno 4096 Dec 21 2013 ..
-rw------- 1 u32473 dyno 16160 May 9 2013 libaio.a
lrwxrwxrwx 1 u32473 dyno 37 May 9 2013 libaio.so -> /lib/x86_64-linux-gnu/libaio.so.1.0.1
drwx------ 2 u32473 dyno 4096 May 17 16:57 pkgconfig
But when I run heroku run ls -l /lib/x86_64-linux-gnu/libaio.so.1.0.1 there is no file there. So the real problem is where are libaio installed?
Anyone can help me make this work? Or there is another good substitution for cx_Oracle?
Thanks!
I solve this... the problem was really the location of the libaio.so.
I started to look for all possibles places where this lib could be installed. I found it in /app/.apt/lib/x86_64-linux-gnu and not in /app/.apt/usr/lib/x86_64-linux-gnu, where heroku-buildpack-apt think it was installed, nor in any of the system lib folders.
So I added this path in LD_LIBRARY_PATH and everything works fine!
Ty All!!!
I was also stuck with the same problems and fixed it after putting some efforts. I am sharing here the steps for hosting python flask app which connects external Oracle Database:
cd {ProjectDir}
pip install cx_Oracle
pip install gunicorn
Make file with name Procfile and put following in it: web: gunicorn yourapp:app --log-file=- //yourapp is your flask python file
pip freeze > requirements.txt
git init
create heroku
heroku buildpacks:add heroku/python
heroku buildpacks:add https://github.com/featurist/oracle-client-buildpack
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-apt
heroku config:set BUILD_WITH_GEO_LIBRARIES=1 //This is for shapely python package
(Optional)
create file with name Aptfile and put libaio1 in it
git push heroku master
set DYLD_LIBRARY_PATH=$ORACLE_HOME and LD_LIBRARY_PATH=$ORACLE_HOME and try again

Categories