dannyroa
dannyroa

Reputation: 5571

Heroku/Django: Could not import user-defined GEOMETRY_BACKEND "geos"

I'm getting the following error on Heroku:

django.core.exceptions.ImproperlyConfigured: Could not import user-defined GEOMETRY_BACKEND "geos".

It's weird because it was working before.

I set the buildpack to https://github.com/dulaccc/heroku-buildpack-geodjango/.

In my settings.py, I have:

GEOS_LIBRARY_PATH = environ.get('GEOS_LIBRARY_PATH')
GDAL_LIBRARY_PATH = environ.get('GDAL_LIBRARY_PATH')

When I deploy to Heroku, it seems to find GEOS. Here's the log:

-----> Checking for GEOS
   Installed
   GEOS installed and accessible with env variable 'GEOS_LIBRARY_PATH'
-----> Checking for Proj.4
   Installed
   Proj.4 installed and accessible with env variable 'PROJ4_LIBRARY_PATH'
-----> Checking for GDAL
   Installed
   GDAL installed and accessible with env variable 'GDAL_LIBRARY_PATH'

Upvotes: 9

Views: 3519

Answers (2)

Jeff Miller
Jeff Miller

Reputation: 588

This error is due to an incorrect install directory path. This fork of heroku-geo-buildpack corrected this issue in their latest commit.

https://github.com/Tekco/heroku-geo-buildpack

Upvotes: 1

7wonders
7wonders

Reputation: 1648

I just ran into the exact same error but I am using the multi buildpack method from ddollar https://github.com/ddollar/heroku-buildpack-multi which has been working perfectly up until this morning.

$ heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
$ cat .buildpacks

# .buildpacks
https://github.com/cyberdelia/heroku-geo-buildpack.git
https://github.com/heroku/heroku-buildpack-python

As you say, it seems to find/install the geos and gdal libs but django doesnt. This is because django wants the full path as per the docs:

https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/geolibs/

So in my case I added to my settings.py the following:

GEOS_LIBRARY_PATH = "{}/libgeos_c.so".format(environ.get('GEOS_LIBRARY_PATH'))
GDAL_LIBRARY_PATH = "{}/libgdal.so".format(environ.get('GDAL_LIBRARY_PATH'))

Now it is all good again.

Upvotes: 0

Related Questions