Installing QGIS 3.8 Zanzibar in Ubuntu 18.04
First, let’s go over some introduction. QGIS is an application create, edit, visualize, analyze and publish geospatial information on Windows, Mac, Linux, BSD. Geospatial data can be shapes, tiles etc.
I discovered QGIS when I was working with Postgis to create a geospatial database. I had to validate the data and draw some shapes over one other from db itself and QGis seamlessly integrates with PostGIS, but more on that later.
Installing QGIS on ubuntu required a lot of hit and trials, a very hardcore googling and some luck.
Here’s the page: https://qgis.org/en/site/forusers/alldownloads.html#debian-ubuntu
for official instruction on installing it in ubuntu. It is pretty straightforward but it didn’t work for me . If these instructions work for you, then great you don’t need to read any further. The instructions will be for3.8
version and I am not sure whether it will work for other versions. But some fixes are very generic to every installation process.
Standard Installation Process
- Add the package source in the apt source list (Take special note on this step)
echo "deb https://qgis.org/ubuntugis bionic main" | sudo tee -a /etc/apt/sources.list
- Add the GPG key (updating as per the new key)
wget -O — https://qgis.org/downloads/qgis-2019.gpg.key | gpg — import - Verify the key (Optional)
gpg — fingerprint 51F523511C7028C3
- Add the key to apt
gpg — export — armor 51F523511C7028C3 | sudo apt-key add -
- Install the package
sudo apt update && sudo apt-get install qgis python3-qgis qgis-plugin-grass
If the last step probably doesn’t work for you, then you can look at the following possible solutions.
Change Source and find what works for you
Change the source in /etc/apt/sources.list
. From the qgis installation page switch between the 3 listed sources but do only one at a time
- Open
etc/apt/sources.list
in your text editor (nano,vim, sublime)
- Scroll down to the last line
- Switch between the following sources
- Choose only one source at a time
deb https://qgis.org/debian bionic main
deb https://qgis.org/ubuntu bionic main
deb https://qgis.org/ubuntugis bionic main
- After each step do
sudo apt update && sudo apt-get install qgis python3-qgis qgis-plugin-grass
- If this works for you, great! If not try to find a source with minimum broken packages.
Install external libraries on your own
- If it’s listing more than 3 files then I wouldn’t recommend them installing manually as that will bloat your system
- If it’s
python3-qgis-common, qgis-common
then add them to the previous install command - Some of the packages exist in
gdal2
, install it by usingsudo apt install gdal-bin
If this doesn’t change anything then remove this package usingsudo apt purge gdal-bin
- Follow the above process for
libgdal-dev
One Specific problem with
gdal-abi-x-x
This is a very specific problem in with QGis installation. The above mentioned virtual package provided by libgdal20
To make qgis
accept it as a dependency we will install the virtual package manually.
- Create
gdal_abi.txt
file and with the follwing text. Make sure you change the version as per your environment
Section: misc
Priority: optional
Standards-Version: 3.9.2
Package: gdal-abi-x-x-x
Version: x.x.x
Depends: libgdal20
Description: virtual package for qgis which needs a gdal-abi-x-x-x
- Install
equivs
, this will be used to create a virtual packagesudo apt install equivs
- Make the virtual package
sudo equivs-build gdal_abi.txt
- Now you will see the
gdal-abi-x-x-x.deb
file in your directory. Install it usingdpkg
sudo dpkg -i gdal-abi-x-x-x.deb - Try installing
qgis
again
Please comment on any other problem you faced.
In case you want to reverse and do a clean install or remove everything related to QGis altogether here’s a small reference
- Remove all packages related to
qgis
sudo apt purge qgis* python3-qgis* - Remove
gdal
andlibgdal-dev
sudo apt purge gdal-bin libgdal-dev
- Remove the key
sudo apt-key del 51F523511C7028C3
gpg --delete-key 51F523511C7028C3
Sources:
- https://linuxhint.com/install-qgis3-geospatial-ubuntu/
- https://qgis.org/en/site/index.html
- https://semiautomaticclassificationmanual-v5.readthedocs.io/en/latest/installation_ubuntu.html
- https://help.ubuntu.com/community/Repositories/CommandLine
- https://help.ubuntu.com/community/GnuPrivacyGuardHowto
- https://packages.ubuntu.com/source/bionic/gdal
- https://mothergeo-py.readthedocs.io/en/latest/development/how-to/gdal-ubuntu-pkg.html
- https://gis.stackexchange.com/questions/216780/cannot-install-qgis-2-18-from-repository-on-debian-stretch-package-gdal-abi-2
- https://askubuntu.com/questions/604988/how-to-remove-a-apt-key-which-i-have-added
- http://blog.chapagain.com.np/gpg-remove-keys-from-your-public-keyring/
P.S. The key will expire on August 18th, 2019
(this month). They should update it in the few days or so, but it doesn’t affect the installation process
Update (22th August 2019) the new key was published on 8th August 2019. I have updated the blog as per the changes.
See you in August 2020 for the same issue 😛