1

In ubuntu 16.04 with postgresql 9.3 when I tried to install postgis with using command

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

It installed postgresql 9.6 and postgis-9.6 version. And when tried to create extension it gives error

CREATE EXTENSION postgis;
ERROR: could not open extension control file "/usr/share/postgresql/9.3/extension/postgis.control": No such file or directory.

Also two servers are running

postgres@db:~$ psql
psql (9.6.3, server 9.3.17)
Type "help" for help.
  • Why do you need to install such an old version (9.3) ? Ubuntu 16.04 defaults to Postgres 9.5. Version 9.6 and 9.3 are both not available . I assume you used some repositories. I guess you used an outdated howto. Such information should be included in the question. – pLumo Jul 19 '17 at 12:33
2

You explicitely installed Version 9.3 and implicitely installed 9.6 as thepostgis package depends on it. But I don't know why you're missing the postgis extension files for 9.3 then.

You can list dependencies of a package:

sudo apt-cache depends postgis

Installing just postgis should be enough.


Fix by uninstalling older Version:

Remove version 9.3:

sudo apt-get purge postgresql-9.3-postgis-2.1 postgresql-9.3

Keeping multiple PostgreSQL installations; How to use a specific version:

When multiple versions are installed, a new PostgreSQL cluster is used for each. You need to specify a cluster when using psql:

psql --cluster 9.6/main -d "YOUR_DATABASE" -c "CREATE EXTENSION postgis;"

List available clusters:

pg_lsclusters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.