10

I am on Ubuntu 18.04 with the psql (PostgreSQL) 12.2 (Ubuntu 12.2-2.pgdg18.04+1)

Running temba=# create extension postgis; fails with the following error

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

I ran find /usr -name postgis.control only to find out postgis.control is inside a folder named 12 instead of 10

laptop@xyz-x:~$ find /usr -name postgis.control
/usr/share/postgresql/12/extension/postgis.control

Edit 1

I have already ran sudo apt-get install postgis

Reading package lists... Done
Building dependency tree       
Reading state information... Done
postgis is already the newest version (3.0.1+dfsg-2.pgdg18.04+1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
nishon.tan
  • 969
  • 2
  • 8
  • 21

8 Answers8

22

I ran this sudo apt install postgis postgresql-10-postgis-2.5 and it worked

nishon.tan
  • 969
  • 2
  • 8
  • 21
  • 1
    The Ubuntu software database thru 19.10 is Postgres v10. That's why you apt-get created into a folder /10/ instead of /12/. Ubuntu 20.04 is supposed to go with Postgres v12. However Postgis 2.5 is (at least should be) compatable with Postgres 10 and 12. So maybe just copy /10/ to /12/ any retry to create extession. – Belayer Apr 11 '20 at 17:26
10

I was not sure what version of postgres or postgis I needed, so I found sudo apt install postgis postgresql-postgis worked.

It either gave me the latest, or matched my installed postgres version.


scy7he
  • 101
  • 1
  • 2
3

I use Linux Mint and had this problem for postgres10, and also: could not access file "$libdir/postgis-2.4": No such file or directory following that. Installation of specific extension and scripts package cures it for me:

sudo apt install postgresql-10-postgis-2.4 postgresql-10-postgis-2.4-scripts Reading package lists... Done Building dependency tree Reading state information... Done postgresql-10-postgis-2.4-scripts is already the newest version (2.4.3+dfsg-4). postgresql-10-postgis-2.4-scripts set to manually installed. The following NEW packages will be installed libprotobuf-c1 postgresql-10-postgis-2.4

Then go, in my case to pgAdmin and CREATE EXTENSION postgis; returns successfully.

Hugh Barnard
  • 352
  • 2
  • 12
2

sudo apt install postgis postgresql-13-postgis-3 for postgres 13.1 and next CREATE EXTENSION postgis; (postgres command)

salius
  • 918
  • 1
  • 14
  • 30
1

Alternatively, and easier, run sudo apt install postgis postgresql-12-postgis-2.5 for postgres12

karuoro
  • 541
  • 4
  • 12
1
  1. Go to the file location where postgis is installed;

    C:\Program Files\PostgreSQL\12\bin

  2. Run stackbuilder.exe;

  3. Select connected your database;

  4. Select "Spatial Extensions" and install

buddemat
  • 4,552
  • 14
  • 29
  • 49
Adem
  • 41
  • 1
  • 4
0

If CREATE EXTENSION postgis is not working and giving you the error no such file or directory.then do follow the following steps:

Go to the file location where postgis is installed;

1.C:\Program Files\PostgreSQL\12\bin 2.Run stackbuilder.exe; 3.Select connected your database; 4.Select "Spatial Extensions" and install

and if you are stackbuilder is not responding wait for some time try with fast internet connection.

0

For PostgreSQL 14: sudo apt install postgis postgresql-14-postgis-3 Tested on Ubuntu 20.04

MaxDragonheart
  • 1,117
  • 13
  • 34