When calling GdalUtils.version(), the returned information is


While I can identify GDAL2, I´m unsure about the next version steps. It could be 2.1.1 or 2.0.1 or 2.1.1.

Currently, the newest GDAL is 2.1.2 so I assume that it means 2.1.1. Can somebody verify that?

Also, the output of GdalUtils.version() should be updated to return proper version information.

Here is the complete Python script (macOS):

import os
import sys
from qgis.core import *
from osgeo import ogr
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.gui import *
QgsApplication.setPrefixPath(r'/Applications/QGIS.app/Contents', True)
app = QgsApplication([], True)
from processing.core.Processing import Processing
import processing

from processing.algs.gdal.GdalUtils import GdalUtils

2 Answers 2


I suppose that the version comes directly from GDAL. See the source code https://trac.osgeo.org/gdal/browser/trunk/gdal/gcore/gdal_version.h. Probably GDAL and QGIS developers would appreciate if you could show a place where to improve the documentation.

The code looks like this:

/* GDAL_COMPUTE_VERSION macro introduced in GDAL 1.10 */
/* Must be used ONLY to compare with version numbers for GDAL >= 1.10 */
#define GDAL_COMPUTE_VERSION(maj,min,rev) ((maj)*1000000+(min)*10000+(rev)*100)

With this formula your version is 2.1.1.

  • Thanks! Well, my suggesting would be to place proper points between maj , min and rev so that GdalUtils.version() returns 2.1.1 instead of 2010100. I´ll open a ticket.
    – pat-s
    Jan 22, 2017 at 18:18
  • Isn't that code for computers and not for humans? For computers it is easy to find that 2010100<2010200 but not as easy to compare strings 2.1.1 and 2.1.2, or 2.1.11.
    – user30184
    Jan 22, 2017 at 18:25
  • Maybe the output is needed in this format in other functions. Then I´ll just do a local modification. I´ll see what the QGIS team thinks.
    – pat-s
    Jan 22, 2017 at 20:49

According to your path ( /Applications/QGIS.app/Contents/Resources/python/plugins) you work on Mac OS X. If you use a version of KyngChaos, GDAL is installed in /Library/Frameworks/GDAL.framework and you don't need QGIS to return the proper GDAL version information.

If you have followed the procedure outlined in the ReadMe.rtf file (GDAL_Framework-2.1.2-1.dmg)

You can type in the Terminal.app

gdalinfo --version

Or in the Python shell

from osgeo import gdal
print gdal.__version__

Because you can perfectly use the GDAL library without QGIS

  • My system-wide GDAL is installed using homebrew. Regardless, I try to access QGIS GDAL platform independent using the processing module from QGIS. So I need to use the GdalUtils way.
    – pat-s
    Jan 22, 2017 at 20:47

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.