52

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?

3
  • Did you download (and build) the PostGIS extension? It is not included by default in a Postgres installation. Commented Sep 9, 2013 at 10:23
  • 1
    I installed it using apt-get install postgis Commented Sep 9, 2013 at 10:25
  • Hey Xeen, what is your final solutions.. please update i have same issue...do all below things but not solve still. Commented Jul 23, 2014 at 8:15

15 Answers 15

26

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

Sign up to request clarification or add additional context in comments.

5 Comments

postgres 9.1 is still installed, try removing it
Does neither work with 9.1 nor 9.3 when doing sudo -u postgres psql -c 'create extension postgis;' : FEHLER: konnte nicht auf Datei »$libdir/postgis-2.1« zugreifen: Datei oder Verzeichnis nicht gefunden
Thanks buddy i solve same issue after remove 9.1 and install 9.3
What about for Windows?
@imray I suggest you ask a new question for help on Windows. Don't forget to search first :)
26

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.

4 Comments

I already had this installed, but I can't find the specific control files that my postgres is complaining about. Maybe the database I'm importing is coming from a different version of postgis or something.
This still works on Ubuntu, substituting postgresql-9.3-postgis-scripts for the package.
apt-get install postgresql-XYZ-postgis-scripts worked for me, where XYZ is the major version of PostgreSQL
This resolved the issue for me on Ubuntu 20.04!
11

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

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

4 Comments

I already had this installed, so it's not necessarily the right answer. Still, good to have it posted. +1
+1 for this answer as well. It's way to enable extensions. Found solution here.
Linux Mint 18 Sarah - installing postgres-contrib-9.4 did the trick
This fixed it for me on a Debian 7 (Wheezy) installation, did not need "postgresql-9.1-postgis" at all.
5

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

2 Comments

Not sure which version of Ubuntu you're using. For me on 12.04, Daniel's answer worked but I couldn't find the package you listed.
I used sudo apt-get install postgresql-9.1-postgis-2.1.
4

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.

Comments

4

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.

1 Comment

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

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..

Comments

3

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!

Comments

2

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.

Comments

2

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

Comments

2

Try this

apt-get install postgis

Comments

0

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.

Comments

0

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

Comments

0

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

Comments

0

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

2 Comments

Can you expand and explain? OP asked why.
when you are execute CREATE EXTENSION postgis; query, it will search the reference file from "directory/postgresql/version/extension/postgis.control" location and it's not available, so you can manually install postgis bundle and later you can execute the CREATE EXTENSION postgis;query . P.S. you need to checked postgis option in between installation process

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.