Python-qgis version info
Can someone tell me how I get the version information for python-qgis ?
I've tried all the usual foo.version
either foo.__version__
or foo.version
. If anyone knows how to do this it will be a great help!
+3
source to share
2 answers
You can use qgis.utils.QGis.QGIS_VERSION
:
>>> import qgis.utils
>>> qgis.utils.QGis.QGIS_VERSION
'2.0.1-Dufour'
+5
source to share
In QGIS3 this changed to ( Qgis
instead of Qgis
)
>>> import qgis.utils
>>> qgis.utils.Qgis.QGIS_VERSION
'3.1.0-Master'
The way to find out if 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
0
source to share