The environment variable (Win10) PYQGIS_STARTUP points to a python script that is executed before QGIS starts (cp. Central deployment of startup.py in QGIS).
Now I need to determine the QGIS version in the python script PYQGIS_STARTUP points to. Of course, this does not work (Answer to Getting user's QGIS version using PyQGIS?):
try:
from qgis.core import Qgis
except ImportError:
from qgis.core import QGis as Qgis
if Qgis.QGIS_VERSION_INT >=30000:
#do something
else:
#do something else or nothing
resulting in
ModuleNotFoundError: No module named 'qgis'
Is there another way to determine QGIS version in such script or am I lost?