When I trying to import MTF Estimator in a fresh installation of QGIS 3.22.1 the plugin manager complains about:
Couldn't load plugin 'mtf_estimator' due to an error when calling its classFactory() method
ModuleNotFoundError: No module named 'gdal'
Traceback (most recent call last):
File "C:\PROGRA~1/QGIS32~1.1/apps/qgis/./python\qgis\utils.py", line 423, in _startPlugin
plugins[packageName] = package.classFactory(iface)
File "C:\Users/Imisystem/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\mtf_estimator\__init__.py", line 35, in classFactory
from .mtf_estimator import MtfEstimator
File "C:\PROGRA~1/QGIS32~1.1/apps/qgis/./python\qgis\utils.py", line 888, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\Users/Imisystem/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\mtf_estimator\mtf_estimator.py", line 28, in
from .mtf_estimator_algorithm import Mtf, Transect, sigmoid
File "C:\PROGRA~1/QGIS32~1.1/apps/qgis/./python\qgis\utils.py", line 888, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\Users/Imisystem/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\mtf_estimator\mtf_estimator_algorithm.py", line 22, in
import gdal
File "C:\PROGRA~1/QGIS32~1.1/apps/qgis/./python\qgis\utils.py", line 888, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'gdal'
I've replaced import gdal with
try:
from osgeo import gdal
except ImportError:
import gdal
in mtf_estimator_algorithm.py
and also the standard import of osr, ogr and gdal in mtf_estimator.py with:
try:
from osgeo import gdal
except ImportError:
import gdal
try:
from osgeo import ogr
except ImportError:
import ogr
try:
from osgeo import osr
except ImportError:
import osr
When I trying to import MTF Estimator in a fresh installation of QGIS 3.22.1 the plugin manager complains about:
I've replaced
import gdal
within
mtf_estimator_algorithm.py
and also the standard import of osr, ogr and gdal in
mtf_estimator.py
with:And it seems to work now.
Please, consider making this a permanent change.