3

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?

  • Suggest you upgrade to a supported version of Ubuntu. 16.10 is end of life as of 20 July 2017. – user2856 Dec 21 '17 at 21:13
  • @Luke I have compatibility issues with some software, that's why I am stuck for the moment with 16.10 – Duccio A Dec 23 '17 at 11:32
  • You still can put a current build of Ubuntu, gdal and python in a virtual box under your 16.10 host OS. Otherwise, you have to build gdal from source. – AndreJ Dec 24 '17 at 7:08
  • BTW adding ubuntugis unstable ppa is useless becuse that does not support Ubuntu 16.10. And I wonder where you got GDAL 2.2.1 from. The main ubuntu repo lists that for artful (17.10) only. – AndreJ Dec 25 '17 at 14:07
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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