Here will be my sequence of command lines while trying to install gdal2.1 in a UBUNTU virtual machine. My virtual machine is a UBUNTU 16.04 LTS(64bit) I would need gdal2.1 and especially the Python bindings to work with it in python. The versionof python currently working is 2.7.11+ and I installed numpy as I know that it is necessary for GDAL. now the command lines with the instruction I found in the Pypi page of GDAL2.1:

antonio19812@antonio19812-VirtualBox:~$ sudo apt-get install libgdal1i

Lettura elenco dei pacchetti... Fatto

Generazione albero delle dipendenze

Lettura informazioni sullo stato... Fatto

libgdal1i is already the newest version (1.11.3+dfsg-3build2).

0 aggiornati, 0 installati, 0 da rimuovere e 62 non aggiornati.

antonio19812@antonio19812-VirtualBox:~$ sudo apt-get install libgdal1-dev

Lettura elenco dei pacchetti... Fatto

Generazione albero delle dipendenze

Lettura informazioni sullo stato... Fatto

libgdal1-dev is already the newest version (1.11.3+dfsg-3build2).

0 aggiornati, 0 installati, 0 da rimuovere e 62 non aggiornati.

antonio19812@antonio19812-VirtualBox:~$ sudo pip install gdal

Collecting gdal Downloading GDAL-2.1.0.tar.gz (619kB) 100% |████████████████████████████████| 624kB 247kB/s

Installing collected packages: gdal

Running setup.py install for gdal ... error

Complete output from command /usr/bin/python -u -c "import setuptools, 


exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n',

'\n'), file, 'exec'))" install --record /tmp/pip-eOB65J-record/install-

record.txt --single-version-externally-managed --compile:

running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying gdal.py -> build/lib.linux-x86_64-2.7
copying ogr.py -> build/lib.linux-x86_64-2.7
copying osr.py -> build/lib.linux-x86_64-2.7
copying gdalconst.py -> build/lib.linux-x86_64-2.7
copying gdalnumeric.py -> build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/osgeo
copying osgeo/gdal.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/gdalconst.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/osr.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/__init__.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/ogr.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/gdal_array.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/gnm.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-2.7/osgeo
running build_ext
building 'osgeo._gdal' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/extensions
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/usr/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-2.7/extensions/gdal_wrap.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
extensions/gdal_wrap.cpp:3085:22: fatal error: cpl_port.h: File o directory non 


compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-_sHDUY/gdal/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-eOB65J-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_sHDUY/gdal/

This was what I obtained. Consider that the VM has not other software or packages installed. I hope you can help me, using GDAL2.1 would be so important..

  • @Luke, please consider adding your comment as an answer so we can consider this question resolved. – Aaron May 17 '16 at 3:38
  • 3
    Ah yes, the Python 2.8 un-release (PEP 404). – Mike T May 17 '16 at 5:07
  • ok now I will provide the sequence of command line in my virtual machine. I prefer to work with a VM because I want to work in linux while my OS is Windows8.1 and I do not want to modify nothing on it. – Antonio May 18 '16 at 0:16

You can download GDAL 2.1 for Windows from GIS Internals. There is an installer and a portable version that doesn't require installation.

GDAL 2.1 is available for Ubuntu 16.04 from the UbuntuGIS-Unstable PPA

sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt update 
sudo apt upgrade # if you already have gdal 1.11 installed 
sudo apt install gdal-bin python-gdal python3-gdal # if you don't have gdal 1.11 already installed 
  • 1
    Just to clarify: You have GDAL 1.11.3 installed, and the repository you want to install from does not provide a newer package. So you have to add another resource, that has a GDAL 2.1 package. Like the Ubuntugis-unstable PPA. – AndreJ May 18 '16 at 5:44
  • yes I have libgdal-dev 1.11.3 and libgdal 11.3 , that could be the reason? – Antonio May 18 '16 at 18:08
  • @Antonio Don't use pip. Just add the ubuntugis-unstable PPA and upgrade. Also make sure you have python-gdal installed for python 2.7 support or python3-gdal for python 3.4 support – Luke May 18 '16 at 20:21
  • Great solution. I can import gdal using python 2 using this approach, but not python 3. Any suggestions on installing gdal with the python3 bindings? – Aaron May 17 '18 at 4:21
  • 1
    Check that the osgeo package gets installed to /usr/lib/python3/dist-packages when you apt-get install python3-gdal and check that /usr/lib/python3/dist-packages is in your python path (and that you installed gdal-bin;) I don't have access to 16.04 anymore (unless I build a vm/docker) so can't test. But I've pretty much stopped using system package managers and just maintain identical conda envs that "just work" (tm) on my Windows and various Linux environments. – Luke May 17 '18 at 4:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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