Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CREATE EXTENSION postgis fails,

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.
like image 284
nishon.tan Avatar asked Apr 11 '20 13:04

nishon.tan


5 Answers

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.


like image 145
scy7he Avatar answered Oct 13 '22 04:10

scy7he


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

like image 31
nishon.tan Avatar answered Oct 13 '22 06:10

nishon.tan


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.

like image 3
Hugh Barnard Avatar answered Oct 13 '22 05:10

Hugh Barnard


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

like image 2
salius Avatar answered Oct 13 '22 05:10

salius


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

like image 1
karuoro Avatar answered Oct 13 '22 06:10

karuoro