[GIS] Error when installing QGIS 2.x and 3.0 on Ubuntu 16.04 and Ubuntu 17.10

installationlinuxqgisubuntugis

I am attempting to install QGIS 3.0 on Ubuntu 16.04 and am failing. Outlined below are the steps I've taken to install and troubleshoot this failure. If anyone has any tips on how to troubleshoot this further, I would be greatly appreciative.

I previously had QGIS 2.18 installed. Prior to my attempt to install QGIS 3.0, I uninstalled QGIS 2.18 by running sudo apt-get purge --auto-remove qgis. I then ran sudo apt-get install qgis and received the following output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have 
requested an impossible situation or if you are using the unstable 
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 qgis : Depends: python-qgis (= 1:3.0.0+24xenial-ubuntugis) but it 
 is not going to be installed
        Depends: qgis-providers (= 1:3.0.0+24xenial-ubuntugis) but it 
        is not going to be installed
        Recommends: qgis-plugin-grass but it is not going to be installed
 E: Unable to correct problems, you have held broken packages.

I am attempting to install from http://qgis.org/ubuntugis xenial main. As I understand this is currently the only repository with a QGIS 3.0 package built. At the moment I'd be happy with a 2.x version so I did the following:

  1. Removed deb http://qgis.org/ubuntugis xenial main and deb-src http://qgis.org/ubuntugis xenial main from /etc/apt/sources.list.
  2. Added deb http://qgis.org/debian xenial main and deb-src http://qgis.org/debian xenial main to /etc/apt/sources.list.
  3. Saved /etc/apt/sources.list.
  4. sudo apt-get purge
  5. sudo apt-get update
  6. sudo apt-get install qgis

This produced a similar result as before. Some packages could not be installed... and then:

The following packages have unmet dependencies:
 qgis : Depends: python-qgis (= 1:2.18.16+24xenial) but it is not
        going to be installed
E: Unable to correct problems, you have held broken packages.

I followed the same 6-step process above to switch to deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu xenial main, again with a similar result:

The following packages have unmet dependencies:
 qgis : Depends: python-qgis (= 2.14.22+dfsg-1~xenial2) but it is not 
        going to be installed
E: Unable to correct problems, you have held broken packages.

I have attempted to attack this using the recommendations found here:

  • sudo apt-get clean
  • sudo apt-get autoclean
  • Attempt to fix broken dependencies:
    • sudo apt-get -f install
    • sudo dpkg --configure -a
    • sudo apt-get -f install
    • Result: 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
      • I understand this to mean that no broken dependencies were fixed.
  • Remove held packages:
    • sudo apt-get -u dist-upgrade
      • Result: 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    • sudo apt-get -o Debug::pkgProblemResolver=yes dist-upgrade
      • Result: `0 upgraded, 0 newly installed, 0 to remove and 0 not
    • I understand these results to mean that no held packages were found or removed.

I also attempted to find the broken held packages by running dpkg --get-selections | grep hold. This returned nothing which I understand might mean this is not actually a broken held packages issue.

Does anyone have a recommendation on how to resolve this broken held records issue or any tips on how to troubleshoot this problem further?

UPDATE 1
I did manage to get QGIS 2.8 installed via aptitude but have been unable to upgrade to QGIS 3.

UPDATE 2
Tried to follow the guide that brianbancroft posted and am still getting the same error about held broken packages. I have also just tried installing the packages listed in the error individually, but I just keep running into a chain of unmet dependencies until I eventually get to a point where a package has no installation candidate. For example, in my latest error, after running sudo apt-get install python-qgis-common, I get:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

 The following packages have unmet dependencies:
python-qgis-common : Depends: python3-gdal but it is not going to be 
installed
E: Unable to correct problems, you have held broken packages.

So I tried running sudo apt-get install python3-gdal. This yielded:

The following packages have unmet dependencies:
 python3-gdal : Depends: gdal-abi-2-2-1
E: Unable to correct problems, you have held broken packages.

I then ran sudo apt-get install gdal-abi-2-2-1, which finally yielded:

Package gdal-abi-2-2-1 is a virtual package provided by:
  libgdal20 2.2.1+dfsg-2build3 [Not candidate version]

E: Package 'gdal-abi-2-2-1' has no installation candidate

Interestingly, I went through this process of trying to install dependencies for python-qgis and qgis and eventually ended up at E: Package 'gdal-abi-2-2-1' has no installation candidate.

I have to admit, I'm a bit lost on this…

Best Answer

Currently, deb https://qgis.org/ubuntugis xenial main is the only option that worked for me to get QGIS 3.0 on Ubuntu 16.04. See, e.g. my related question installing QGIS 3.0 on Ubuntu? and the discussions therein.

Debian repo stopped updating a long time ago due to dependency issues (about GDAL).

Related Question