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
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
postgres$ which psql
postgres$ pg_config --pkglibdir

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.


Does this tell anyone anything?

delirium:~ ap257$ otool -L /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)

4 Answers 4


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.

  • 1
    +1 I was getting this same error. Turns out, I had a couple of other postgres installs. Blowing them all way and then installing postgis with homebrew worked for me.
    – Casey
    Jan 3, 2012 at 17:42

Do you have another simultaneous installation of Postgres that might be conflicting?

What does ldd return?:

ldd /usr/local/pgsql/lib/postgis-1.5.so

Also, see this suggestion from another report of the issue.

  • Thanks! ldd (actually otool for Mac) returns as shown above. I suspect there is another leftover installation of postgres and that is the root of the problem - however I can't find another pg_config on my machine (using mdfind).
    – AP257
    Aug 3, 2010 at 12:51
  • 1
    I just tried installing on a OS X box, and it worked as expected. Could you try hardcoding the path in the first entry of postgis.sql to /usr/local/pgsql/lib to see if it has any effect?
    – scw
    Aug 4, 2010 at 0:16
  • Bizarrely, rebooting fixed the problem. Your suggestion sounds like a good one, though. Thanks!
    – AP257
    Aug 4, 2010 at 13:39
  • FWIW, hardcoding the path as @scw suggests works for me
    – yalestar
    Aug 3, 2011 at 20:52

Esse erro aconteceu comigo, mas foi justamente pq tinha dois servidores (8.4 e 9.1) instalados, a solução foi remover a versão 8.4.


This error happened to me, but it was actually because I had two servers (8.4 and 9.1) installed. The solution was to remove the 8.4 version.


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy