CREATE EXTENSION postgis fails, - postgresql

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.

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

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.

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.

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

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

Go to the file location where postgis is installed;
C:\Program Files\PostgreSQL\12\bin
Run stackbuilder.exe;
Select connected your database;
Select "Spatial Extensions" and install

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.

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

Related

CREATE LANGUAGE plperlu; fails despite postgresql-plperl-12 being installed

I'm on an Ubuntu-derived system (specifically pop_os from System76). I am trying to get Bucardo installed, but it appears to be failing because plperlu is not functional.
In a psql prompt:
# CREATE LANGUAGE plperlu;
ERROR: could not access file "$libdir/plperl": No such file or directory
However, running:
$ pg_config --pkglibdir
/usr/lib/postgresql/12/lib
and:
$ ls /usr/lib/postgresql/12/lib/plperl*
/usr/lib/postgresql/12/lib/plperl.so
I do have the postgresql-plperl-12 package installed:
# apt install postgresql-plperl-12
Reading package lists... Done
Building dependency tree
Reading state information... Done
postgresql-plperl-12 is already the newest version (12.7-0ubuntu0.20.10.1).
0 upgraded, 0 newly installed, 0 to remove and 32 not upgraded.
All the related errors I could find related either to the relevant package not being installed or the language not being created in postgres, so I'm a little stymied. The CREATE LANGUAGE statement's error appears to indicate that Postgres is looking for a file without an extension, but I'm not sure if that's fixable by a simple mv, and if so, who to report a package bug to.
Edit:
Prompted by #AdrianKlaver's comment:
# CREATE EXTENSION plperlu;
ERROR: could not open extension control file "/usr/share/postgresql/10/extension/plperlu.control": No such file or directory
... now why is it looking in /usr/share/postgresql/10/?
I may be misinterpreting, but I have:
$ psql --version
psql (PostgreSQL) 12.7 (Ubuntu 12.7-0ubuntu0.20.10.1)
plperlu.control does exist in /usr/share/postgresql/12/extension/... but SELECT version() is indeed PostgreSQL 10.10... so something somewhere has gone wrong during an update. Does having a psql version that differs from the actualy postgres that is running cause issues?
The issue is that there are multiple versions of Postgres running as servers. Running pg_lsclusters will show what they are. The CREATE EXTENSION fails as the extension code for the version of Postgres that the command is being run on has not been installed.
Got the same problem on Debian 11 and Postgres 12. Solution that worked for me:
apt update
apt install -y postgresql-server-dev-12 wget
wget https://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-12/postgresql-plperl-12_12.10-1.pgdg20.04+1+b1_amd64.deb
dpkg -i ./postgresql-plperl-12_12.10-1.pgdg20.04+1+b1_amd64.deb
apt --fix-broken install # because problems on dpkg command
apt list --installed | grep postgresql-plperl-12

How do i install postgis on ubuntu server?

My pc showing i have two versions of Postgres installed.
postgres=# \c viserver
psql (12.2 (Ubuntu 12.2-4), server 11.7 (Ubuntu 11.7-0ubuntu0.19.10.1))
I installed PostGIS using sudo apt-get install postgis but it installed PostGIS in Postgres 12.
But I want to install it in Postgres 11. cause my server version using postgres 11.
because CREATE EXTENSION postgis; on a database giving error
ERROR: could not open extension control file "/usr/share/postgresql/11/extension/postgis.control": No such file or directory
the error you see means that some packages are not installed.
To have postgis.control please check and install
postgresql-11-postgis-X.Y (e.g. X.Y = 2.5)
and
postgresql-11-postgis-X.Y-scripts
Regards,
Mohamad
It helped what S. Mohamad explained. But I want to share the exact answer.
Steps to resolve the error:
Try to run sudo apt install postgresql-11-postgis. This will install but provide suggestion what to install like below.
You can see the 2 versions of postgis I installed the latest version by sudo apt install postgresql-11-postgis-3
After installing required package you can run CREATE EXTENSION postgis; in postgres and it will show you following:
Yay!! No errors.

postgres cannot create extension postgis

i installed postgres on a new vps and then i installed postgis, but trying to create a postgis extension i always get this error:
create extension postgis;
ERROR: could not load library "/usr/lib/postgresql/10/lib/rtpostgis-2.4.so": /usr/lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20)
i have no idea how to solve it.
i also tried to install openssl and libssl-dev but didn't help
edit:
i am using 18.04.4 LTS ubuntu
i install issuing:
sudo apt install postgresql postgresql-contrib
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install postgis
Issue with Ubuntu 18.04
For missing OpenSSL 1.1.1 on Ubuntu 18.04 take a look at this answer. You might need to download the .deb file and install it manually.
PostgreSQL 10 and PostGIS 2.4
In this article a similar error is solved by creating a symbolic link to the rtpostgis library available in the system, so that you can trick PostGIS 2.4 into thinking that the file exists, e.g. rtpostgis-2.5.so to rtpostgis-2.4.so:
$ ln -s rtpostgis-2.4.so rtpostgis-2.5.so
PostgreSQL 10 and PostGIS 3
To install PostGIS 3 (newer version) in a PostgreSQL 10 environment try:
sudo apt-get install postgresql-10-postgis-3
After that you will have the required libraries to perform CREATE EXTENSION postgis.

Install Postgis in Ubuntu 16.04 in with already postgresql 9.3 installed

In ubuntu 16.04 when I tried to install postgis with using apt-get install postgis postgresql-9.3-postgis-2.1 this command, it installed postgresql 9.6 and postgis-9.6 version. And when tried to create extension it gives error ERROR: could not open extension control file "/usr/share/postgresql/9.3/extension/postgis.control": No such file or directory.
postgres#db:~$ psql
psql (9.6.3, server 9.3.17)
Type "help" for help.
It seems that you didn't use sudo before apt-get which is causing issue with write permissions of your directory.
To prevent this error remove the installed version and reinstall it with sudo like,
sudo apt-get install postgis postgresql-9.3-postgis-2.1
Read more related with your issue and follow the steps to install specific version.

Can't use uuid and create an extension to use it

I want to use uuid in Postgresql 9.2 on Ubuntu 13. So when I tried to check whether is available or not, I did:
select uuid_generate_v4() as one;
And it gave me ERROR: function uuid_generate_v4() does not exist
Then I did CREATE EXTENSION "uuid-ossp";
ERROR: could not open extension control file "/usr/share/postgresql/9.2/extension/uuid-ossp.control": No such file or directory
Well, what do I do next?
By the way, SELECT * FROM pg_available_extensions; returns plpsql (1.0) only.
The operating system package that contains the extension is not installed. To install it:
apt-get install postgresql-contrib-9.2
For anyone using the asdf version manager with the asdf-postgres plugin, installing postgres versions as follows fixes this issue:
POSTGRES_EXTRA_CONFIGURE_OPTIONS=--with-uuid=e2fs asdf install postgres <VERSION>
For you guys, who installed postgres using postgres rpm repo on Fedora or similar distro:
sudo dnf install postgresql-contrib
installs a package from default fedora repo, which conflicts with postgres, like:
/usr/pgsql-12/lib/libpq.so.5: no version information available (required by psql)
Right way is
sudo dnf install postgresql12-contrib
You can double check it during install, it has to be from pgdg12, same as postgresql-server
(you have insert your postgres version instead of '12')
If you still get the error, try to run manually the two SQL files inside /usr/share/postgresql/9.X/extension/uuid-ossp*.sql into your database