I have been installed postgis following this guide. All is OK.

SELECT postgis_full_version();
"POSTGIS="2.1.7 r13414" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.10.1, released 2013/08/26" LIBXML="2.9.1" LIBJSON="UNKNOWN" TOPOLOGY RASTER"

But I have not the shp2pgsql in /usr/lib/postgresql/9.4/bin as you can see:

foo@bar:/usr/lib/postgresql/9.4/bin$ ls
clusterdb   initdb             pg_dump         pg_standby      psql
createdb    oid2name           pg_dumpall      pg_test_fsync   reindexdb
createlang  pg_archivecleanup  pg_isready      pg_test_timing  vacuumdb
createuser  pg_basebackup      pg_receivexlog  pg_upgrade      vacuumlo
dropdb      pgbench            pg_recvlogical  pg_xlogdump
droplang    pg_controldata     pg_resetxlog    postgres
dropuser    pg_ctl             pg_restore      postmaster

Why this happens? and how can I install it?

  • Not sure about linux but on Windows shp2pgsql is in with the PostGis\bin and not postgresql\bin.. – Michael Stimson May 26 '15 at 3:01

I was also following the OP's installation method of PostgreSQL and PostGIS, namely

sudo apt-get install postgresql-9.4-postgis-2.1 pgadmin3 postgresql-contrib-9.4

I enabled the PostGIS extension in a database but didn't get shp2pgsql to work until I did

sudo apt-get install postgis

as listed toward the bottom of the page. Why postgresql-9.4-postgis-2.1 doesn't include shp2pgsql and simply postgis does .... I'm not really sure. But PostgreSQL, PostGIS, and shp2pgsql are all working fine now.

  • Same goes for Fedora – TheSteve0 Sep 11 '19 at 4:17

When installing postgis on Linux, be sure to install the client also, as postgis on its own will not install the shp2pgsql executable.

yum install postgis2_94
yum install postgis2_94-utils
yum install postgis2_94-client

Until you install the client, there is just a link in /usr/bin/ pointing to /etc/alternatives/postgis-shp2pgsql. This is just an empty link until the client install places the executables in /usr/pgsql-9.4/bin.

Hope this helps, appreciate the OP asked the question some months ago and I hope found a resolution sooner.


Normally, the shp2pgsql binary is in /usr/bin/shp2pgsql when you install with packages like in the method you mentioned.

Did you type shp2pgsql in command line? Normally, it works out of the box.

If not,

  • did you do an updatedb (command line to index files) followed with a locate shp2pgsql to find the real binary path?

  • did you echoed the output from the command line using echo $PATH? And what is the output?

  • Command sudo locate shp2pgsql is empty. Command echo $PAHT returns /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games – Overflow012 May 26 '15 at 22:04
  • Because sudo locate shp2pgsql is empty, it seems you didn't installed shp2pgsql properly (or you forgot to do sudo updatedb). If the package name is the same for additional repo and the default, doing a sudo apt-get install postgis should install both shp2pgsql and shp2pgsql-gui. This answer is based on the fact I supposed you are using a Debian based distro (Debian, Mint or Ubuntu) – ThomasG77 May 27 '15 at 0:51
  • I run sudo shp2pgsql and sudo apt-get install postgis but keeps the error foo@bar:/usr/lib/postgresql/9.4$ shp2pgsql bash: /usr/local/bin/shp2pgsql: No existe el archivo o el directorio – Overflow012 May 27 '15 at 2:28

Try updating first, and then proceed from there:
sudo apt-get update.

Seems dumb, but I was having trouble with my installations of psql and postgis and it all cleared up once I updated.

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.