python-qgis version information

2019-07-03 10:00发布

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!

2条回答
forever°为你锁心
2楼-- · 2019-07-03 10:13

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
查看更多
女痞
3楼-- · 2019-07-03 10:23

You can use qgis.utils.QGis.QGIS_VERSION:

>>> import qgis.utils
>>> qgis.utils.QGis.QGIS_VERSION
'2.0.1-Dufour'
查看更多
登录 后发表回答