Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python-qgis version information

Can someone tell me how I get the version information for python-qgis?

I have tried all the usual foo.version or foo.__version__ or foo.VERSION. If someone knows how to do this, it would be a great help!

like image 298
Mike Avatar asked Jun 25 '26 19:06

Mike


2 Answers

UPDATE: As of QGIS 3+, this is now in qgis.core.Qgis.QGIS_VERSION

Original answer:

You can use qgis.utils.QGis.QGIS_VERSION:

>>> import qgis.utils
>>> qgis.utils.QGis.QGIS_VERSION
'2.0.1-Dufour'
like image 75
falsetru Avatar answered Jun 28 '26 08:06

falsetru


In QGIS3, this has changed to (Qgis instead of QGis)

>>> import qgis.utils
>>> qgis.utils.Qgis.QGIS_VERSION
'3.1.0-Master'

A way to figure out whether the version is >=3.0 or not seems to be

(QGIS >=3.0)

>>> import qgis.utils
>>> hasattr(qgis.utils, 'Qgis')
True

(QGIS <= 2.18)

>>> import qgis.utils
>>> hasattr(qgis.utils, 'Qgis')
False
like image 24
LuWi Avatar answered Jun 28 '26 09:06

LuWi