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!
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!
You can use qgis.utils.QGis.QGIS_VERSION
:
>>> import qgis.utils
>>> qgis.utils.QGis.QGIS_VERSION
'2.0.1-Dufour'
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