5

I am having trouble getting a simple GeoDjango app running on heroku. I have created the postgis extension for my database but I am not able to run syncdb without getting the following error:

from django.contrib.gis.geometry.backend import Geometry
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/geometry/backend/__init__.py", line 14, in <module>
'"%s".' % geom_backend)
django.core.exceptions.ImproperlyConfigured: Could not import user-defined GEOMETRY_BACKEND "geos".

Any ideas what I am doing wrong? Also does anyone know of a tutorial for getting a simple geodjango project running on heroku? Thanks for your help

6
  • check this out: pragmaticstartup.wordpress.com/2012/09/30/… Commented May 28, 2013 at 2:15
  • This may be useful if I were experiencing this problem locally but it's happening on my heroku app. Commented May 28, 2013 at 2:28
  • Have you solved the problem yet? Commented Aug 25, 2013 at 19:17
  • no I never solved the issue. Commented Aug 25, 2013 at 22:25
  • @theStreaker123: You still having this issue? I'm getting this in Heroku. Weird thing is it used to work then it suddenly stopped working. Commented Mar 13, 2014 at 19:56

3 Answers 3

3

I ran into this same issue and Joe is correct, you are missing a buildpack. What I did differently was include both the heroku-geo-buildpack and the heroku-buildpack-python. Both can be included by using the heroku-buildpack-multi and adding a ".buildpacks" file to your home directory in which to include the other buildpacks.

https://github.com/ddollar/heroku-buildpack-multi

So set buildpack-multi as your buildpack and add a .buildpacks file in your project base directory:

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

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

When you push this, Heroku will install the software packages required to run python (python, pip, etc), along with the software packages required to run postgis (geos, proj and gdal).

I gave heroku-buildpack-geodjango a try but I believe it might be out of date (hasn't been updated in a year).

Sign up to request clarification or add additional context in comments.

1 Comment

i am getting a django.core.exceptions.ImproperlyConfigured: Cannot determine PostGIS version for database "d17s5j1dssat5d4pe". GeoDjango requires at least PostGIS version 1.3. Was the database created from a spatial database template? when i try to heroku run python manage.py migrate. Any idea whts wrong??
2

I just ran into the exact same error after using the multi buildpack method from ddollar https://github.com/ddollar/heroku-buildpack-multi with no problems up until this morning. As Jeff writes, you just point your buildpack at the multi and then add a .buildpacks file.

$ 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

Also dont forget to add django.contrib.gis to the apps in settings.

Everything should go well and install the geos and gdal libs when you push to heroku but you will find that django doesnt find them and you get the error. This is because django wants the full path as per the docs:

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

So add this to settings.py:

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

1 Comment

adding library_paths did it for me
1

It seems like you are missing some C libraries. Consider the GeoDjango Heroku buildpack:

https://github.com/cirlabs/heroku-buildpack-geodjango/

heroku create --stack cedar --buildpack http://github.com/cirlabs/heroku-buildpack-geodjango/
git push heroku master

The required libraries should be installed automatically using these commands.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.