QGIS, PostgreSQL, PostGIS – Fixing Broken Packages and Unmet Dependencies on Ubuntu 14.04

postgispostgresqlqgis

I am aware that this could be a duplicate topic but I am struggling for a several days.
I upgraded QGIS from 2.8 to 2.18 and after that everything get broken. I couldn't use PostGIS extension on pgadmin3.

I figured out that there were a conflict with a libgdal1h: if installed, it removes other libraries used by PostGIS and vice versa.

I tried several tutorial about how to install QGIS, like for example:

How do I get and install the latest version of QGIS in Ubuntu?

Install QGIS 2.14 Essen on Ubuntu 16.04 Xenial

I tried every suggestion reported on line, like for example:

https://askubuntu.com/questions/351899/qgis-quantum-gis-install-fails-unmet-dependencies

https://askubuntu.com/questions/621406/dist-upgrade-in-ubuntu-14-04-uninstalled-qgis-and-results-in-unmet-dependencies

Where to find a version of libgeos-c1 compatible with libgeos-3.5.0?

QGIS install on Ubuntu 14.04 fails

Always, the reply of sudo apt-get install qgis python-qgis is:

The following packages have unmet dependencies:


python-qgis : Depends: python-qt4-sql but it is not installable
               Depends: python-qgis-common (= 1:2.14.8+20trusty-ubuntugis) but it is not going to be installed
               Depends: python-psycopg2 but it is not installable
               Depends: python-qscintilla2 but it is not installable
               Depends: python-jinja2 but it is not installable
               Depends: python-markupsafe but it is not installable
               Depends: python-pygments but it is not installable
               Depends: python-yaml but it is not installable
               Depends: python-pyspatialite but it is not installable
               Depends: libqgispython2.14.8 but it is not going to be installed
               Depends: libqgis-analysis2.14.8 but it is not going to be installed
               Depends: libqgis-core2.14.8 but it is not going to be installed
               Depends: libqgis-gui2.14.8 but it is not going to be installed
               Depends: libqgis-networkanalysis2.14.8 but it is not going to be installed
               Depends: libqgis-server2.14.8 but it is not going to be installed
               Recommends: liblwgeom-dev but it is not installable
 qgis : Depends: gdal-abi-2-1-0 but it is not installable
        Depends: libgdal20 (>= 2.0.1) but it is not installable
        Depends: libgeos-c1v5 (>= 3.4.2) but it is not installable
        Depends: libqgis-analysis2.14.8 but it is not going to be installed
        Depends: libqgis-app2.14.8 but it is not going to be installed
        Depends: libqgis-core2.14.8 but it is not going to be installed
        Depends: libqgis-gui2.14.8 but it is not going to be installed
        Depends: libqgis-networkanalysis2.14.8 but it is not going to be installed
        Depends: qgis-providers (= 1:2.14.8+20trusty-ubuntugis) but it is not going to be installed
        Depends: qgis-common (= 1:2.14.8+20trusty-ubuntugis) but it is not going to be installed
        Recommends: qgis-plugin-globe but it is not going to be installed
        Recommends: qgis-plugin-grass but it is not going to be installed
        Recommends: qgis-provider-grass but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I have removed all the packages and the libraries so I do not have any library related to postgis, postgres and QGIS with the Synaptic Package Manager and all with the commands:

sudo apt-get purge qgis
sudo apt-get autoremove qgis
sudo apt-get --purge remove qgis
sudo apt-get update

But the problem is not solved yet.

I tried to remove the repo of ubuntugis and/or debian on the file /etc/apt/sources.list.

Nothing.

And I do not understand why, using this source http://qgis.org/ubuntugis/ I still have issues about the dipendences.

What should I do?

I am planning to format my laptop hoping this will help me with broken packages..
for the broken packages, I have already tried:

sudo apt-get update –fix-missing
sudo apt-get install -f

but nothing fixed.

Best Answer

I had faced a similar problem installing qgis. I finally got it installed using aptitude package manager.

Try this first:

sudo apt-get update then sudo apt-get -f install.

If that doesn't work try the higher level package manager aptitude.

sudo aptitude install qgis python-qgis qgis-plugin-grass

It gives multiple solutions like this and you can select one.

Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

      Downgrade the following packages:                                                                    
1)      libqt4-declarative [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)]
2)      libqt4-network [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)]    
3)      libqt4-opengl [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)]     
4)      libqt4-script [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)]     
5)      libqt4-sql [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)]        
6)      libqt4-sql-sqlite [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)] 
7)      libqt4-svg [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)]        
8)      libqt4-xml [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)]        
9)      libqt4-xmlpatterns [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)]
10)     libqtcore4 [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)]        
11)     libqtdbus4 [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)]        
12)     libqtgui4 [4:4.8.7+dfsg-7ubuntu1~xenialoverlay1~1 (now) -> 4:4.8.7+dfsg-5ubuntu2 (xenial)]         


Accept this solution? [Y/n/q/?] y
The following packages will be DOWNGRADED:
  libqt4-declarative libqt4-network libqt4-opengl libqt4-script libqt4-sql libqt4-sql-sqlite libqt4-svg libqt4-xml libqt4-xmlpatterns libqtcore4 libqtdbus4 libqtgui4 
The following NEW packages will be installed:
  libdrm-dev{a} libfcgi0ldbl{a} libgl1-mesa-dev{a} libglade2-0{a} libglu1-mesa-dev{a} libjs-jquery-ui{a} libjs-leaflet{a} liblwgeom-dev{a} libqca2{a} libqca2-plugin-ossl{a} libqca2-plugins{a} 
  libqgis-analysis2.18.3{a} libqgis-app2.18.3{a} libqgis-core2.18.3{a} libqgis-customwidgets{a} libqgis-gui2.18.3{a} libqgis-networkanalysis2.18.3{a} libqgis-server2.18.3{a} libqgisgrass7-2.18.3{a} 
  libqgispython2.18.3{a} libqjson0{a} libqt4-dbus{a} libqt4-designer{a} libqt4-dev{a} libqt4-dev-bin{a} libqt4-help{a} libqt4-opengl-dev{a} libqt4-qt3support{a} libqt4-scripttools{a} libqt4-test{a} 
  libqtassistantclient4{a} libqwt5-qt4{a} libspatialindex4v5{a} libx11-xcb-dev{a} libxcb-dri2-0-dev{a} libxcb-dri3-dev{a} libxcb-glx0-dev{a} libxcb-present-dev{a} libxcb-randr0-dev{a} libxcb-render0-dev{a} 
  libxcb-shape0-dev{a} libxcb-sync-dev{a} libxcb-xfixes0-dev{a} libxdamage-dev{a} libxext-dev{a} libxfixes-dev{a} libxshmfence-dev{a} libxxf86vm-dev{a} mesa-common-dev{a} python-cycler{a} python-dateutil{a} 
  python-future{a} python-gdal{a} python-glade2{a} python-httplib2{a} python-jinja2{a} python-markupsafe{a} python-matplotlib{a} python-matplotlib-data{a} python-pygments{a} python-pyparsing{a} 
  python-pyspatialite{a} python-qgis python-qgis-common{a} python-qscintilla2{a} python-qt4{a} python-qt4-sql{a} python-shapely{a} python-sip{a} python-tz{a} python-yaml{a} qdbus{a} qgis qgis-common{a} 
  qgis-plugin-grass qgis-plugin-grass-common{a} qgis-provider-grass{a} qgis-providers{a} qgis-providers-common{a} qt4-designer{a} qt4-linguist-tools{a} qt4-qmake{a} x11proto-damage-dev{a} 
  x11proto-dri2-dev{a} x11proto-fixes-dev{a} x11proto-gl-dev{a} x11proto-xext-dev{a} x11proto-xf86vidmode-dev{a} 
The following packages are RECOMMENDED but will NOT be installed:
  qt-at-spi 
0 packages upgraded, 88 newly installed, 12 downgraded, 0 to remove and 57 not upgraded.
Related Question