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
Related
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. 🤜🏽🤛🏽
I'm trying to deploy an app with Heroku, but it's not working... I have looked at a bunch of other posts on here with the same error, but I'm not finding what's wrong.
I have Python 3.8.5 installed on my machine which is supported by Heroku-18, but for whatever reason when I do "git push heroku master" it sees python 3.8:
-----> Python app detected
! Requested runtime (python 3.8) is not available for this stack (heroku-18).
! Aborting. More info: https://devcenter.heroku.com/articles/python-support
! Push rejected, failed to compile Python app.
I have the runtime.txt file with python-3.8.5:
python-3.8.5
I also checked the version on my PC specifically, and tried reinstalling to no success, either:
$ python -V
Python 3.8.5
And, again, it's supported as of July, 21st, 2020:
https://devcenter.heroku.com/changelog-items/1833
I guess the question would be, how do I get Heroku to recognize that I have the correct version installed? I'm sure it's something small I'm overlooking, but I can't figure it out.
Here's my directory showing it's in the root directory:
/my_site (masterbranch)
$ ls
about_app/
ckeditor/
my_site/
staticfiles/
blog_app/
contact_app/
home_app/
media/
static/
templates/
requirements.txt
Procfile
Procfile.windows
runtime.txt
db.sqlite3
manage.py*
runtime.txt:
$ cat runtime.txt
python-3.8.5
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!
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.
I'm following tutorial from http://www.marinamele.com/2013/12/how-to-set-django-app-on-heroku-part-i.html and I can't pass the section with foreman -> guicorn configuration. My django app is in myproject directory.
When I'm trying to run command from my virtualenv, console freeze, but django app works in my browser - but foreman can't work properly
(myenv) ... gunicorn myproject.wsgi
But when I run:
(myenv) ... gunicorn myproject:wsgi
I got Failed to find application: 'myproject'.
my requirements.txt:
Django==1.6.5
argparse==1.2.1
gunicorn==19.0.0
wsgiref==0.1.2
this might of some help;
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/gunicorn/
especially below 2 lines
This requires that your project be on the Python path; the simplest way to ensure that is to run this command from the same directory as your manage.py file