PostGIS – Fix ‘Could Not Open Extension Control File’ Error

postgispostgresql

I've followed the instructions here to install PostGIS
http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS21UbuntuPGSQL93Apt but when I went to create the extension I got the following error. I'm using PostgreSQL 9.3.2 and Ubuntu 12.04. The extension doesn't appear in the dropdown list on pgadmin3 either.

# create extension postgis;
ERROR:  could not open extension control file "/opt/PostgreSQL/9.3/share/postgresql/extension/postgis.control": No such file or directory

Best Answer

Looks like you have more than one PostgreSQL install. You're connected to a PostgreSQL install from EnterpriseDB, in /opt. This install cannot see, or use, extensions installed into the Ubuntu-packaged PostgreSQL install.

The instructions you followed will have installed PostgreSQL 9.3 from http://apt.postgresql.org/, i.e. PGDG. You should connect to that PostgreSQL install, not the EnterpriseDB one, if you want to use the PostGIS you installed.

You need to either use the system-packaged (PGDG) PostgreSQL install on your system, or install PostGIS separately into the EnterpriseDB-packaged PostgreSQL install using their StackBuilder product.