I am using EnterpriseDB to run Postgis.

when I run "shp2pgsql" on got an error message.

~ macbook$ shp2pgsql
-bash: shp2pgsql: command not found
~ macbook$ which shp2pgsql

I read that I should find it in this directory, but It seems that I am missing that file.

~ macbook$ ls /Library/PostgreSQL/9.3/bin/

clusterdb       pg_controldata      pgbench
createdb        pg_ctl          pgsql2shp
createlang      pg_dump         pltcl_delmod
createuser      pg_dumpall      pltcl_listmod
dropdb          pg_isready      pltcl_loadmod
droplang        pg_receivexlog      postgres
dropuser        pg_resetxlog        postmaster
ecpg            pg_restore      psql
initdb          pg_standby      raster2pgsql
oid2name        pg_test_fsync       reindexdb
pg_archivecleanup   pg_test_timing      shp2pgsql
pg_basebackup       pg_upgrade      vacuumdb
pg_config       pg_xlogdump     vacuumlo

when I run this comma /Library/PostgreSQL/9.3/bin/shp2pgsql.sh Outlines.shp city | psql -d City

It says: -bash: psql: command not found -bash: shp2pgsql.sh: command not found

How can I run this command ? should I go for shp2pgsql-gui loader ?

  • Maybe add that folder to your PATH. How to do that is not GIS specific.
    – BradHards
    Feb 6 '14 at 5:00

I haven't used the EnterpriseDB installer before, so I'm not sure if it installs shp2pgsql by default.

You can confirm whether or not you do have shp2pgsql installed, however, by performing the following commands:

# Update your search database
$ sudo /usr/libexec/locate.updatedb
# Execute search for shp2pgsql
$ locate shp2pgsql

The output of this command for me is as follows:

Matthews-MacBook-Pro-2:scripts matt$ locate shp2pgsql

Looking more specifically at /usr/local/bin/shp2pgsql on my system, we can see that it's symbolically linked to /usr/local/Cellar/postgis/2.1.1/bin/shp2pgsql

Matthews-MacBook-Pro-2:scripts matt$ ls -lath /usr/local/bin/shp2pgsql
lrwxr-xr-x  1 matt  admin    37B Dec  7 20:31 /usr/local/bin/shp2pgsql -> ../Cellar/postgis/2.1.1/bin/shp2pgsql

So, if the output of the locate command on your Mac shows that shp2pgsql has been installed, but is not in your /usr/local/bin directory, you might be able to get away with creating the symlink in /usr/local/bin, pointing it to the actual file path to shp2pgsql.

See this link on creating symlinks: http://justinwalker.me/2012/02/better-than-an-alias-create-a-symbolic-link-in-mac-os-x/

  • after following your instructions, i got this prob: dyld: Library not loaded: @loader_path/../lib/liblwgeom-2.1.1.dylib Feb 6 '14 at 5:39
  • Same issue, but with OpenGeo Suite it's installed in /usr/local/opengeo/bin/shp2pgsql. I'm adding usr/local/opengeo/bin to my PATH
    – aaryno
    Aug 23 '15 at 0:47

I got the same

dyld: Library not loaded: @loader_path/../lib/liblwgeom-2.1.1.dylib

Full Code:

Last login: Mon Feb 10 18:19:48 on ttys000 Daniels-MacBook-Pro:~ Danny$ /Library/PostgreSQL/9.3/bin/shp2pgsql ; exit; dyld: Library not loaded: @loader_path/../lib/liblwgeom-2.1.1.dylib Referenced from: /Library/PostgreSQL/9.3/bin/shp2pgsql Reason: image not found Trace/BPT trap: 5 logout

[Process completed]

  • How did you solve that ? Feb 12 '14 at 8:11

The easiest way (I can now run the tool though I've not yet loaded any data) is to add an export line to your ~/.bash_login file (assuming you're using bash):

export DYLD_LIBRARY_PATH="/Library/PostgreSQL/9.3/lib/postgresql:$DYLD_LIBRARY_PATH"

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.