GeoDjango setup: ERROR: could not access file "$libdir/postgis-1.5": No such file or directory

AP257 picture AP257 · Jul 31, 2010 · Viewed 7.3k times · Source

Update: thought I'd solved it, but I hadn't... please see below.


I'm installing GeoDjango on Mac OSX. I've followed the 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 found these instructions from postgis IRC, but 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

I installed postgres and its PostGIS extensions from KyngChaos. 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 being found.

Answer

Jeppe Mariager-Lam picture Jeppe Mariager-Lam · Oct 21, 2011

I know this an old question, but i found it using Google, so others might end up here as well.

On my Mac OSX macports install, i had two folders with .so files for postgresql:

/opt/local/lib/postgresql90/

and

/usr/local/pgsql-9.0/lib/

It seems like my installation looked in /opt/local/lib/postgresql90/ and not in /usr/local/pgsql-9.0/lib/, so to install pg_trgm, i had to do the following:

sudo ln -s /opt/local/lib/postgresql90/pg_trgm.so /usr/local/pgsql-9.0/lib/

This should work with any .so file which is not in the right place - In your example it would have been

sudo ln -s /opt/local/lib/postgresql90/postgis-1.5.so /usr/local/pgsql-9.0/lib/

Which allows me to install postgis as well :)