sudo apt-get install postgresql-9.5-postgis-2.5

returns a series of errors:

The following packages have unmet dependencies:
postgresql-9.5-postgis-2.5 : 
  Depends: libgdal1i (>= 1.9.0) but it is not installable
  Depends: libjson-c2 (>= 0.11) but it is not installable
  Depends: liblwgeom-2.5-0 (>= 2.5.0~beta1) but it is not going to be installed
  Depends: libproj9 (>= 4.9.0) but it is not installable
  Depends: libsfcgal1 (>= 1.2.0) but it is not installable

E: Unable to correct problems, you have held broken packages.

I had never encountered a not installable exception to date so I ma not sure of consequences of different possible actions... Attempting lower versions leads to the same result. How can PostGIS get safely installed then?


An attempt was also made, making a fresh installation of a Ubuntu 18.04 VM [following these instructions][1]

The source of the error was in adding the repository to sources.list

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt xenial-pgdg main" >> /etc/apt/sources.list'

which should be for 18.04

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt bionic-pgdg main" >> /etc/apt/sources.list'

[to butter things up even more, and attempt was made with bioni-pgdg main leading to its own set of errors]!


2 Answers 2


Unmet Dependencies

The UbuntuGIS Quickstart Guide lists a few things that need to be done before installing their packages (these packages include PostGIS).

The first is that your /etc/apt/sources.list must include the "universe" and "multiverse" repositories. Edit that file to add them. There should already be a line that lists "main". In the end, it will look like this:

deb http://archive.ubuntu.com/ubuntu bionic main  
deb http://archive.ubuntu.com/ubuntu bionic-security main  
deb http://archive.ubuntu.com/ubuntu bionic-updates main  

deb http://us.archive.ubuntu.com/ubuntu/ bionic main universe multiverse  
deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main universe multiverse  
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main universe multiverse

This is where all of your dependencies come from.

Install Repository

After that, you need to install the UbuntuGIS repository

sudo add-apt-repository ppa:ubuntugis/ppa

Once this is done, you should be able to install postgis in the typical way:

sudo apt install postgis

Note: there will be a lot of items to install.


Ensure that the proper repository is added to the sources.list

sudo lsb_release -a 

ensure the codename is the same in the add repository command:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt **Codename**-pgdg main" >> /etc/apt/sources.list'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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