5

I am trying to run the following shp2pgsql cmd using the OSGeo4W shell:

shp2pgsql -s 4269 -g geom_4269 -I -W "latin1"
"tl_2012_states" staging.tl_2012_states | 
psql -h localhost -p 5432 -d dvdtwo -U postgres

but I am getting the following error:

'shp2pgsql' is not recognized as an internal or external command, operable program or batch file

I have tried updating the environment variable path to include the PostgreSQL\9.5\bin, but that hasn't worked.

What should I try next, or what do you think my problem is?

I am using, PosgreSQL 9.5, QGIS 2.18.5, PostGIS 2.0

  • 2
    If you set the environment in a right way you should not get that message. For example you can open the OSGeo4W shell and run set path=%path%;C:\path_to\PostgreSQL\9.5\bin and if the added path is correct then shp2pgsql just must be found. – user30184 May 4 '17 at 14:33
  • @user30184 probably not a good idea, see my answer. MS Windows is a special snowflake. – Evan Carroll May 4 '17 at 17:35
  • If you run that command in the OSGeo4W shell window it extends the path only in that window. System path is not touched at all. – user30184 May 4 '17 at 18:36
5

is not recognized as an internal or external command, operable program or batch file

OSGeo4W specifically has closed the ticket to add this to the system path. The DLLS may conflict with other system DLLs and cause problems.

You need to statically point to the absolute location of shp2pgsql, in the case of OSGeo4W and with your example, I believe it's

C:\OSGeo4W\bin\shp2pgsql -s 4269 -g geom_4269 -I -W "latin1" "tl_2012_states" staging.tl_2012_states | psql -h localhost -p 5432 -d dvdtwo -U postgres

I got the path from the docs on the directory structure. I have no idea if the docs are correct though.

| improve this answer | |
2

Looking at the OSGEO4W package list, I don't see anything related to Postgis (although psql gets installed). So you can not blame OSGEO4W for the missing path entry.

If the Postgis installation does not add the folder to the path, you simply have to expand the command line with the full path to the exe.

It should be C:\Program Files\PostgreSQL\9.5\bin\shp2sql.exe (or wherever you find it in your installation).

| improve this answer | |

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.