[GIS] struggling with GeoDjango install: ERROR: could not access file “$libdir/postgis-1.5”: No such file

geodjangopostgis

I'm installing GeoDjango on Mac OSX. I've followed the official Mac install instructions, which all went smoothly, and am now creating a spatial database template for PostGIS.

However, when I try to load the PostGIS SQL routines, I get ERROR: could not access file "$libdir/postgis-1.5": No such file or directory:

postgres$ psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
psql:/usr/local/pgsql/share/contrib/postgis-1.5/postgis.sql:59: ERROR:  could not access file "$libdir/postgis-1.5": No such file or directory
<snip>
psql:/usr/local/pgsql/share/contrib/postgis-1.5/postgis.sql:7785: ERROR:  type "geometry" does not exist

What's going wrong, and how can I fix it?

I think I'm running the right version of pg_config, etc:

postgres$ which pg_config
/usr/local/pgsql/bin/pg_config
postgres$ which psql
/usr/local/pgsql/bin/psql
postgres$ pg_config --pkglibdir
/usr/local/pgsql/lib

If I look in /usr/local/pgsql/lib, there is a file called postgis-1.5.so there, so I don't understand why it's not found.

—–UPDATE——-

Does this tell anyone anything?

delirium:~ ap257$ otool -L /usr/local/pgsql/lib/postgis-1.5.so
/usr/local/pgsql/lib/postgis-1.5.so:
        /Library/Frameworks/GEOS.framework/Versions/3/GEOS (compatibility version 4.0.0, current version 4.2.0)
        /Library/Frameworks/PROJ.framework/Versions/4/PROJ (compatibility version 7.0.0, current version 7.6.0)
        /usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.3.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)
        /usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 40.0.0)

Best Answer

Basically the answer (I found) was to make sure you've completely, totally uninstalled any other versions of postgres on your Mac before you begin the GeoDjango installation. I fixed it eventually by nuking the other postgres, and starting again from scratch.