heroku push rejected due to gdal library

Viewed 1100

I wanted to deploy my application in heroku. The platform I am using aredjango 1.11, django-rest-framework, postgresql, gis. When I do git push heroku master, I get the following error

django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal2.1.0", "gdal2.0.0", "gdal1.11.0", "gdal1.10.0", "gdal1.9.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

It says to install GDAL and provide GDAL_LIBRARY_PATH. How do i provide the path for it?

I have also configured for postgresql

heroku addons:create heroku-postgresql:hobby-dev
1 Answers

I had the same issue and had to piece together info from several places.

First, from the official Heroku docs: https://devcenter.heroku.com/articles/postgis#geodjango-setup Add these lines to your settings:

DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'

GDAL_LIBRARY_PATH = os.getenv('GDAL_LIBRARY_PATH')
GEOS_LIBRARY_PATH = os.getenv('GEOS_LIBRARY_PATH')

Also add django.contrib.gis to your INSTALLED_APPS.

Run heroku config:set BUILD_WITH_GEO_LIBRARIES=1 -a name_of_your_app for your app.

Finally, but importantly, run heroku buildpacks:add https://github.com/TrailStash/heroku-geo-buildpack -a name_of_your_app

This worked for me with the heroku-16 stack.

Related