[gdal-dev] Packages on PyPi vs. Ubuntu/Fedora

Even Rouault even.rouault at spatialys.com
Mon Sep 30 05:36:15 PDT 2019

On lundi 30 septembre 2019 12:02:55 CEST Stefan Blumentrath wrote:
> Hi Even,
> And thanks for your swift reply.
> If I install Python bindings like:
> pip3 install gdal==2.4.2
> installation works fine.
> However, if I then install nansat:
> pip3 install nansat
> then pip3 tries to re-install GDALs python bindings for GDAL version 3
> (which fails).
> So, users are caught up in package-mismatches and I was wondering if it
> would be possible to have something like:
> import subprocess
> gdal_version = None
> try:
>     gdal_version = subprocess.check_output(['gdal-config',
> '--version']).decode('utf8').strip('\n') except:
>     print('Warning: Could not identify GDAL version, using default!')
> if not gdal_version:
>     gdal_version = '3.0.0'
> in setup.py for the Python bindings.
> But maybe that messes too much with how pip is supposed to work...?

Can't work. Once pip has downloaded a given version of the GDAL python 
bindings, the setup.py of that package can only built the bindings for that 
particular version, not earlier versions.

That's one of the issue/feature with pip and Python modules that use native 
library. The other approach would be to use wheels, but that's another can of 

Spatialys - Geospatial professional services

More information about the gdal-dev mailing list