PostgreSQL error when trying to create an extension

DatabasePostgresql

Database Problem Overview


ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/postgis.control": No such file or directory

Is what I get when I try to CREATE EXTENSION postgis; can anybody tell me why is it so and what can I do to fix it?

Database Solutions


Solution 1 - Database

The following will get you a working postgis install on Ubuntu 12.04 (Note: also tested on 13.10)

echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/postgis.list
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-9.3-postgis-2.1 postgresql-client-9.3
sudo -u postgres psql -c 'create extension postgis;'

Based on the docs at https://wiki.postgresql.org/wiki/Apt

Solution 2 - Database

You need to install postgresql-9.1-postgis-scripts. In Ubuntu or Debian, you need to run the following command as root:

apt-get install postgresql-9.1-postgis-scripts

This adds the files needed to create the postgis extensions.

Solution 3 - Database

Installing this package did the trick for me on my Linux Mint 16 box:

# install hstore postgresql extension.
sudo apt-get install postgresql-contrib

Solution 4 - Database

Daniel Vérité is close to the truth, but not enough. The package missing is postgresql-9.1-postgis-2.0:

sudo apt-get install postgresql-9.1-postgis-2.0

Solution 5 - Database

Presumably the postgis version you installed is 1.5.x which doesn't come as an extension, but as a couple of SQL scripts that need to be manually applied to create the necessary SQL objects.

Also the postgis package is not enough, it contains only stuff that doesn't depend on PG version, you need postgresql-9.1-postgis (dpkg -L package-name is handy to check out the files provided by any particular package).

Once the installation paths are known, the official install documentation should be good enough to set up the template database.

Solution 6 - Database

Just resolved it. You have to uninstall postgis-1.5. You installed it instaed of PostGIS 2.0. As soon as you will install postgis-2.0 you will see corrected libraries in extension directory. Before installing you should to add a correct repository (see http://docs.pgrouting.org/2.0/en/doc/src/installation/index.html#ubuntu-debian). Use ppa:ubuntugis/ubuntugis-unstable for PostGIS 2.0. Try one of

apt-get remove postgis
apt-get remove postgresql-9.1-postgis
apt-get install postgresql-9.1-postgis

I couldn't remove and install because of dependencies error. After a few attmpts, I just removed postgresql-9.1-postgis and apt-get offer me upgrade it to 2.0.

Solution 7 - Database

I had the same problem on my Window 8.1 setup.

I solved it by simply using Application StackBuilder which comes with Postgres and installing PostGIS again (despite not having uninstalled it)

Works fine now!

Solution 8 - Database

In C:\Program Files\PostgreSQL\9.4 I found uninstall-postgis-bundle-pg94x64-2.1.5-2.exe. Running that fixed my problem, which was caused by a reinstall of PostgreSQL without first uninstalling, and without installing PostGIS the second time around. That's what happens when you more than one person installing stuff..

Solution 9 - Database

Make sure that you have installed this

sudo apt-get install postgresql-9.3-postgis

I was facing same issue due to missing this package.

Solution 10 - Database

On 14.04, there is postgresql-9.3-postgis-scripts, which contains the postgis.control file.

Solution 11 - Database

Try this

apt-get install postgis

Solution 12 - Database

CentOS needs a different package for this problem. For CentOS 6, if you're using the PGDG yum repository at http://yum.pgdgrpms.org/9.3/redhat/, install the postgresql93-contrib package with the command 'yum install postgresql93-contrib.

Update and edit as necessary for PostgreSQL 9.4.

Solution 13 - Database

I had my worst nightmare while installing Postgis 2.X on SLES 12 SP1. which doesnt have compatible package in zypper repo

Here is how is resolved it on my Postgres server instance running 9.4.X

Prerequsite packages which i have installed prior to PostGis based on the errors

Proj 4 Download source cold, Build --> make install
install Gdal andjibson by adding zypper repo zypper addrepo http://download.opensuse.org/repositories/Application:Geo/SLE_12_SP1_Backports/Application:Geo.repo
zypper install gdal gdal-devel libjson-c-devel libjson

Installing Postgis

Download postgis source code (http://download.osgeo.org/postgis/source/postgis-2.3.0rc1.tar.gz)

Go to Postgis folder 
./configure --with-pgconfig=/usr/lib/postgresql94/bin/pg_config --with-geosconfig=/usr/local/bin/geos-config 
make 
make install

now if you goto postgress DB and create extension postgis; it will work

Important while configuring you should specify pg-config path and geosconfig path and You SHOULD NOT include "without Raster" as RASTER plays main role in creating the postgis extension

Solution 14 - Database

this work for me

   SELECT PostGIS_full_version();

To create postgisis run above query in query panel

And for remove postgis from your database run bellow query

   drop extension postgis

Solution 15 - Database

if you are using windows system download the postgis.bundle.exe and manually install in C:/(PostgreSQLdirectory/version/ ) and that's all .

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionXeenView Question on Stackoverflow
Solution 1 - DatabasedwurfView Answer on Stackoverflow
Solution 2 - DatabaseRoldan VargasView Answer on Stackoverflow
Solution 3 - DatabaseAlirezaView Answer on Stackoverflow
Solution 4 - DatabaseLuís de SousaView Answer on Stackoverflow
Solution 5 - DatabaseDaniel VéritéView Answer on Stackoverflow
Solution 6 - DatabaseDmitry LutskovView Answer on Stackoverflow
Solution 7 - DatabaseCodyBugsteinView Answer on Stackoverflow
Solution 8 - DatabasejulianView Answer on Stackoverflow
Solution 9 - Databasevitthal-gaikwadView Answer on Stackoverflow
Solution 10 - Databaseserv-incView Answer on Stackoverflow
Solution 11 - DatabaseSusaj S NView Answer on Stackoverflow
Solution 12 - DatabaseNico Kadel-GarciaView Answer on Stackoverflow
Solution 13 - DatabasePradeep BView Answer on Stackoverflow
Solution 14 - DatabaseSameer KaziView Answer on Stackoverflow
Solution 15 - DatabaseHarshalView Answer on Stackoverflow