[GIS] Ubuntu16.10: install GDAL on Python3.6

gdalinstallationUbuntuubuntugis

I am on Ubuntu16.10. I would like to install GDAL on Python3.6.
I have installed Python3.6 with apt-get install python3.6.
I am installing GDAL with:

apt-get install -y software-properties-common python-software-properties
add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
apt install gdal-bin python-gdal python3-gdal

The problem is that in this way, GDAL is installed on python3.5 not on the 3.6.
The problem seems to be python3-gdal, because:

apt show python3-gdal

gives:

Package: python3-gdal
Version: 2.2.1+dfsg-2build3
Priority: optional
Section: universe/python
Source: gdal
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian GIS Project <pkg-grass-devel@lists.alioth.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 2242 kB
Provides: python3.5-gdal

On Ubuntu16.10 it provides python3.5-gdal. Is there a way to force it to provide python3.6-gdal?

Best Answer

The easiest way to get your preferred GDAL/Python version without the restrictions imposed by your system package manager is to use the conda package management system. You can use this without admin/root privileges as it installs to your home directory and you don't run the risk of messing up your system by installing a non-standard system python.

  1. Install miniconda
  2. Create a conda environment:
    • conda create -n mygdalenv gdal python=3.6 or
    • conda create -c conda-forge -n mygdalenv gdal python=3.6
  3. Activate your new environment:
    • source activate mygdalenv

If you want an IDE, you can use PyCharm with your new environment (sudo snap install pycharm-community --classic), or you can activate it manually then conda install spyder, or if you prefer Jupyter notebooks conda install jupyter