module "images" might not be available

Issue #197 resolved
Benjamin Jakimow created an issue

coreapps\enmapboxapplications\utils.py need to handle the case that the QGIS ressource has not been loaded

Load EnMAPBoxApplication(s) from "enmapboxapplications"
No module named 'images'
Traceback:
  File "C:/Users/geo_beja/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapbox\gui\applications.py", line 278, in addApplicationFolder
    appModule = __import__(appPkgName)
  File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python\qgis\utils.py", line 674, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\Users\geo_beja\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\enmapbox\coreapps\enmapboxapplications\__init__.py", line 4, in <module>
    from enmapboxapplications.imagemathapp.core import ImageMathApp
  File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python\qgis\utils.py", line 674, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\Users\geo_beja\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\enmapbox\coreapps\enmapboxapplications\imagemathapp\core.py", line 732, in <module>
    class ImageMathApp(QMainWindow, loadUIFormClass(pathUi=join(pathUi, 'main.ui'))):
  File "C:\Users\geo_beja\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\enmapbox\coreapps\enmapboxapplications\utils.py", line 71, in loadUIFormClass
    FORM_CLASS, _ = uic.loadUiType(buffer, resource_suffix=RC_SUFFIX)
  File "C:\PROGRA~1\QGIS3~1.0\apps\Python37\lib\site-packages\PyQt5\uic\__init__.py", line 201, in loadUiType
    exec(code_string.getvalue(), ui_globals)
  File "<string>", line 192, in <module>
  File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python\qgis\utils.py", line 674, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)

A quick fix migh be adding a dummy module:

if not 'images' in sys.modules.keys():
    import enmapbox.gui.resourcemockup
    sys.modules['images'] = enmapbox.gui.resourcemockup

Comments (2)

  1. Log in to comment