16

When attempting to fire up the django server, I get the following error:

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

I'm running postgresql8.4 on Mac OS Lion.

I've used Macports to install PostGIS. Here's what $ port installed shows:

postgis @1.5.2_1+postgresql84 postgis @1.5.2_1+postgresql90 postgis @1.5.3_0+postgresql90 postgis @1.5.3_0+postgresql91 (active)

Here's what I get when attempting to determine what version of PostGIS I've got:

geodjango=# SELECT PostGIS_full_version();
ERROR:  could not access file "$libdir/postgis-1.5": No such file or directory
CONTEXT:  SQL statement "SELECT postgis_lib_version()"
PL/pgSQL function "postgis_full_version" line 11 at SQL statement
akaihola
  • 26,309
  • 7
  • 59
  • 69
wmfox3
  • 2,141
  • 4
  • 21
  • 28

4 Answers4

14

Just in case some developers are facing this problem on Ubuntu, I solved it just installing libgeos-lib

sudo apt-get install libgeos-dev

panchicore
  • 11,451
  • 12
  • 74
  • 100
6

I had the same problem with postgis via MacPorts in combination with Django, although I could execute select postgis_full_version(); without issues. This answer helped me: http://pragmaticstartup.wordpress.com/2012/09/30/django-core-exceptions-improperlyconfigured-could-not-import-user-defined-geometry_backend-geos/

The solution for me was to add

export DYLD_FALLBACK_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH:/opt/local/lib/

to ~/.profile. (Don't forget to source it before trying again)

Martijn de Milliano
  • 3,908
  • 3
  • 36
  • 45
6

I found that I'd originally installed geos through pip.

Once I downloaded the new GEOS library from: http://www.kyngchaos.com/software/frameworks#geos

Then installed it.

Last, I added to my path (~/.bash_profile):

export PATH=/Library/Frameworks/GEOS.framework/Versions/3/unix/lib/:$PATH

It worked fine.

JayCrossler
  • 2,079
  • 2
  • 22
  • 22
1

Have you installed the geos library?

It's included in the instructions for installing GeoDjango with macports.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • Yep. Ran the installs outlined on the GeoDjango site using macports, though it's entirely likely some of these were previous installed and therefore things were not in the proper order. – wmfox3 Nov 28 '11 at 01:07