8
votes

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.

2
That most probably is not the whole error message - there should be something before the "ERROR: current transaction is aborted,...".Milen A. Radev
Yes, there is, sorry. The first error is: 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 (I've updated the question to show this).AP257
You may find more expert answers to GIS related questions in the dedicated site gis.stackexchange.comamercader

2 Answers

3
votes

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 :)

0
votes

The file /usr/local/Cellar/postgresql9/9.0.17/lib/postgis-1.5.so is missing. This error happened after brew upgrade and the solution is to uninstall postgis and reinstall it with:

brew uninstall postgis15

brew install postgis15

The result should be: PostGIS plugin libraries installed to: /usr/local/Cellar/postgresql9/9.0.17/lib

So afterwards you should find the file /usr/local/Cellar/postgresql9/9.0.17/lib/postgis-1.5.so