Running Create Extension postgis gives ERROR could not open extension control file?

  • I have installed PostgreSQL 9.x and PostGIS 1.5/2.0 several times and have never had this problem.

    I just got a new CentOS 6.3 server up and running and and I have Postgres 9.3 functioning as expected. I have run

    yum install postgis2_93
    

    and I can see the files in

    /usr/pgsql-9.3/share/contrib/
    

    however, when I run

    CREATE EXTENSION postgis;
    

    I receive

    ERROR:  could not open extension control file "/usr/pgsql-9.3/share/extension/postgis.control": No such file or directory
    

    the tutorials (#1, #2) I have used don't show any steps between installing PostGIS and creating the extension.

    What am I missing?

    What you're missing is 'postgis.control' :) The question is 'why' or 'where'. First, see if you even have a copy by running 'find /usr -name postgis.control'. If you don't, then it's a packaging problem with the brand new postgis2_93 package that needs to be fixed.

    Oh, you can see the files (including 'postgis.control'?) share/contrib, but from the error message pgsql is looking in share/extension. There might have been a change in default extension location from 9.2 to 9.3 that the packager missed.

    @PaulRamsey - I ran `find /usr -name postgis.control` and it is not present. I can see some files in share/contrib; however, postgis.control is not among them... what do you suggest I do? wait for a fix, make my own, something else?

    @PaulRamsey - I just verified that `postgis-2.1.so` is present in `/lib` does this mean I can just make my own postgis.control file?

    If you can find a postgis.sql file, you can run that into your database (and the spatial_ref_sys.sql file) to manually spatialize your database. Report the missing control file to the packager, that's a big problem.

    @PaulRamsey - thanks... if you submit your answer I'll select it.

  • Paul Ramsey

    Paul Ramsey Correct answer

    7 years ago

    If you can find a postgis.sql file, you can run that into your database (and the spatial_ref_sys.sql file) to manually spatialize your database. Report the missing control file to the packager, that's a big problem.

  • I just had the same problem on Ubuntu Server 14.04. I installed the postgis extension from the official Ubuntu repositories using apt-get install postgis.

    Then, find /usr -name postgis.control didn't return any results.

    The reason was extension/postgis.control wasn't installed because postgis-scripts wasn't.

    $ aptitude search postgis
    i   libpostgis-java                                  - Geographic objects support for PostgreSQL -- JDBC support 
    i   postgis                                          - Geographic objects support for PostgreSQL                 
    p   postgis:i386                                     - Geographic objects support for PostgreSQL                 
    i   postgis-doc                                      - Geographic objects support for PostgreSQL -- documentation
    i   postgresql-9.3-postgis-2.1                       - Geographic objects support for PostgreSQL 9.3             
    p   postgresql-9.3-postgis-2.1:i386                  - Geographic objects support for PostgreSQL 9.3             
    i   postgresql-9.3-postgis-2.1-scripts               - PostGIS for PostgreSQL 9.3 -- scripts -- dummy package    
    i   postgresql-9.3-postgis-scripts                   - Geographic objects support for PostgreSQL 9.3 -- scripts 
    

    The solution is to install it.

    On debian-like distros:

    apt-get install postgis*
    

    The aptitude package manager will automatically determine the correct package versions to install. The postgis-doc will be installed too.

    EDIT

    Like some people noticed in comments, the postgis* is not required because it installs some packages not strictly required to just get it to work.

    The required packages are postgis and postgresql-9.x-postgis-scripts meta packages. They select the correct real version for your system. So the commands to install the required packages are

     $ sudo apt-get install postgis postgresql-9.3-postgis-scripts
    

    for postgresql-9.3. Ubuntu 16.04 runs postgresql-9.5 so the command becomes:

     $ sudo apt-get install postgis postgresql-9.5-postgis-scripts
    

    You can check the success of the operation by running the following command:

    find /usr -name postgis.control
    

    On my server, it now returns:

    /usr/share/postgresql/9.3/extension/postgis.control
    

    You can now enable the extension on any database on your postgres server:

    • connect to your db with superuser (postgres by default)
    • run CREATE EXTENSION postgis;

    Your public schema now contains all postgis objects and functions.

    ...wish you had Windows direction too

    ...never mind! Solved it in Windows by reinstalling PostGIS via StackBuilder

    Thanks this fixed my Ubuntu problem! The "postgis*" gets a bunch of stuff you don't need. I think "apt-get install postgis postgresql-9.3-postgis-2.1" is sufficient.

    You're probably right. In my case, a full install was preferable but it doesn't the rule.

    "apt-get install postgis*" rules. Thanks!

    Why asterisk man? Jesus!!

    @Nelson I edited my answer to consider your comment

    @MagnoC I edited my answer to consider your comment

    Working! Thank you.

  • In Ubuntu 14.04 you also need to install the postgresql-9.3-postgis-scripts package. After I ran

    sudo apt-get install postgis postgresql-9.3-postgis-scripts

    I was then able to successfully run

    CREATE EXTENSION postgis;

    in my database to initialise PostGIS.

  • I had the same issue, I just ran the command

    sudo apt-get install postgis
    

    I was using Ubuntu 18.04

    thanks a lot that solved it for me

    no problem :) welcome!

  • Another source which caused the problem could be the missing PostGIS bundle, this can be defined in install menu or in your case afterwards. Therefor, open windows start, head to PostgreSQL an start the Application Stack Builder. Then select PostgreSQL, with that possible applications are loaded. For the PostGIS bundle you just need to install the extension suitable to your operating system (32- or 64bit), simply direct to Spatial Extensions.

    After all here the recommended steps:

    1. start Application Stack Builder
    2. Direct to Spatial Extensions
    3. Install PostGIS bundle

    Now you can add the extension with CREATE EXTENSION postgis; in your SQL Query.

  • I encountered the same problem, I think the problem is that the package postgis2_93 is not installed in the expected place as postgresql would expect. You can try using another repo, which might give you the correct place. Or you can search to add extensions manually by specifying the place. In my case, the file is in /usr/pgsql-9.4/

  • 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

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

    Installing Postgis

    now if you goto postgress and create extension postgis; 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

  • For Ubuntu 16.04 run this command:

    sudo apt-get install postgis postgresql-9.6-postgis-2.3-scripts

    note that you should specify your version number for both postgresql (9.6 in my case) and postgis (2.3 in my case).

  • For me, using Fedora 25 and pg 9.5, it worked when I did the following changes:

    • Install yum postgis package

      $ yum install postgis2_95

    • Download the postgis scripts .deb package

    • Extract it and copy the directories 'contrib' and 'extension' in extracted usr/share/postgresql/9.5 to the the same path in your pgsql (maybe changing permissions to).

    • Restart the server

  • In my case (Linux Mint 18.1 Serena) I had to remove posgresql-9.5 and postgis newly installed from default repository.

    sudo apt remove postgis*
    sudo apt remove postgresql*
    

    And install version 9.6 from PosgreSQL repository:

    sudo apt install postgresql-9.6 postgresql-9.6-postgis-2.3 postgresql-9.6-postgis-2.3-scripts postgresql-contrib-9.6
    

    I'm not sure, version has anything to do with missing postgis.control file. But I wanted 9.6 version anyway.

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM