EnGeoMap crashes upon start

Issue #1356 resolved
Agustin Lobo created an issue

A soon as Application/GFC EnGeoMAP is selected, it crashes:

ImportError: cannot import name 'loadUIFormClass' from 'enmapbox.gui.utils' (/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/gui/utils.py)

Traceback (most recent call last):
  File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/apps/engeomap/enmapboxintegration.py", line 53, in startGUI
    from engeomap.userinterfaces import EnGeoMAPGUI
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/apps/engeomap/userinterfaces.py", line 31, in 
    from enmapbox.gui.utils import loadUIFormClass
ImportError: cannot import name 'loadUIFormClass' from 'enmapbox.gui.utils' (/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/gui/utils.py)

Python version: 3.9.5 (default, Nov 18 2021, 16:00:48) [GCC 10.3.0]
QGIS version: 3.24.2-Tisler Tisler, 13c1a02865

Version 3.10.0.20220401T124144.develop c7d679b

Comments (22)

  1. Helge Daempfling

    Hi, do you use Windows or a Unix/Debian based system (Linux/Mac OS)?

    EnGeoMAP is currently only supported on Windows.

    Best Regards,

    Helge

  2. Agustin Lobo reporter

    I am using linux.

    EnGeoMAP is currently only supported on Windows.

    Then a simple message telling so to the user instead of a crash would nicer. Crashes are a major discredit for any package.

  3. Helge Daempfling

    @Augustin Lobo
    Hi Augustin, we are currently working on a complete revision of EnGeoMAP. I will try to incorporate this or see if can make it run on Linux (also my personal preference)…

    @Andreas Rabe

    I just installed the EnMAP-Box freshly on a windows 11 computer - after downloading all the missing python packages it works. I can’t reproduce this error with the 3_18 branch. Something must have been changed inutils.py( enmapbox.gui.utils ) in the development branch as the error directs to that file. I will look into it and try to find what you changed there.

  4. Helge Daempfling

    Ok, so maybe this solves it:

    open …enmapbox/gui/utils.py

    and try to change the line

    from ..qgispluginsupport.qps.utils import loadUi, SpatialExtent, SpatialPoint, findParent, \ file_search, appendItemsToMenu, zipdir

    to

    from ..externals.qps.utils import *

    or to

    from ..qgispluginsupport.qps.utils import loadUi, SpatialExtent, SpatialPoint, findParent, \ file_search, appendItemsToMenu, zipdir, loadUIFormClass

    and tell me if the error still comes up.

  5. Helge Daempfling

    @Augustin Lobo

    If you want to run the newest version that I recently committed to run on Linux you must changes the following lines in the according files:

    in enmap-box/enmapbox/apps/engeomap/algorithms.py:

    the line from osgeo import gdalnumeric back to import gdalnumeric

    in enmap-box/enmapbox/apps/engeomap/engeomap_aux_funcul.py:

    the line from osgeo import gdal back to import gdal

    and the line from osgeo import gdalnumeric back to import gdalnumeric

    This should allow it to run the newest development branch under Linux.

    I will try to write an OS function that imports GDAL according to the OS used. Actually I believe this should then make EnGeoMAP run under Linux or Debian/Mac OS as well.

  6. Helge Daempfling

    @Augustin Lobo

    It should work with your version as well - Then you would just need open this file on your computer:

    /home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/gui/utils.py

    and change the following lines with a standard text editor:

    from ..qgispluginsupport.qps.utils import loadUi, SpatialExtent, SpatialPoint, findParent, \ file_search, appendItemsToMenu, zipdir

    to

    from ..externals.qps.utils import *

    and save the file. Then restart QGIS and try to load the EnMAP-Box and EnGeoMAP again.

    Kind Regards,

    Helge

  7. Agustin Lobo reporter

    @Helge

    After that change, just starting QGIS:

    Couldn't load plugin 'enmapboxplugin' due to an error when calling its classFactory() method

    ModuleNotFoundError: No module named 'enmapbox.externals'

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/qgis/utils.py", line 423, in _startPlugin
        plugins[packageName] = package.classFactory(iface)
      File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/__init__.py", line 54, in classFactory
        raise ex
      File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/__init__.py", line 49, in classFactory
        from enmapbox.enmapboxplugin import EnMAPBoxPlugin
      File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
        mod = _builtin_import(name, globals, locals, fromlist, level)
      File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/__init__.py", line 396, in 
        from enmapbox.gui.enmapboxgui import EnMAPBox
      File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
        mod = _builtin_import(name, globals, locals, fromlist, level)
      File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/gui/enmapboxgui.py", line 28, in 
        import enmapbox.gui.datasources.manager
      File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
        mod = _builtin_import(name, globals, locals, fromlist, level)
      File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/gui/datasources/manager.py", line 14, in 
        from enmapbox.gui.datasources.datasourcesets import DataSourceSet, ModelDataSourceSet, VectorDataSourceSet, \
      File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
        mod = _builtin_import(name, globals, locals, fromlist, level)
      File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/gui/datasources/datasourcesets.py", line 7, in 
        from .datasources import DataSource, VectorDataSource, RasterDataSource, ModelDataSource, \
      File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
        mod = _builtin_import(name, globals, locals, fromlist, level)
      File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/gui/datasources/datasources.py", line 14, in 
        from .metadata import CRSLayerTreeNode, RasterBandTreeNode, DataSourceSizesTreeNode
      File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
        mod = _builtin_import(name, globals, locals, fromlist, level)
      File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/gui/datasources/metadata.py", line 13, in 
        from enmapbox.gui.utils import dataTypeName
      File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
        mod = _builtin_import(name, globals, locals, fromlist, level)
      File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/gui/utils.py", line 27, in 
        from ..externals.qps.utils import *
      File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
        mod = _builtin_import(name, globals, locals, fromlist, level)
    ModuleNotFoundError: No module named 'enmapbox.externals'
    

    Python version: 3.9.5 (default, Nov 18 2021, 16:00:48) [GCC 10.3.0]
    QGIS version: 3.24.2-Tisler Tisler, 13c1a02865

    Python Path:

    • /usr/share/qgis/python
    • /home/alobo/.local/share/QGIS/QGIS3/profiles/default/python
    • /home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins
    • /usr/share/qgis/python/plugins
    • /home/alobo/OTB/OTB-7.3.0-Linux64/lib/python
    • /usr/lib/python39.zip
    • /usr/lib/python3.9
    • /usr/lib/python3.9/lib-dynload
    • /home/alobo/.local/lib/python3.9/site-packages
    • /usr/local/lib/python3.9/dist-packages
    • /usr/lib/python3/dist-packages
    • /usr/lib/python3.9/dist-packages
    • /home/alobo/.local/share/QGIS/QGIS3/profiles/default/python
    • .
    • /home/alobo/.local/lib/python3.9/site-packages/IPython/extensions
    • /home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages
    • /home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/qgispluginsupport/qps/pyqtgraph

  8. Helge Daempfling

    Hi Augustin,

    sorry then instead of from ..externals.qps.utils import *

    try from ..qgispluginsupport.qps.utils import *

    Maybe this works. As it seems the way the utils are imported changed

  9. Agustin Lobo reporter

    crash solved! but…

    Once the GUI is filled with the file names:

    2022-05-16T12:06:44     WARNING    Python error : An error has occurred while executing Python code: See message log (Python Error) for more details.

    2022-05-16T12:06:44     WARNING    Traceback (most recent call last):

    File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/apps/engeomap/userinterfaces.py", line 124, in startAlgorithm
                  from engeomap.algorithms import engeomapp_headless
                  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
                  mod = _builtin_import(name, globals, locals, fromlist, level)
                  File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/apps/engeomap/algorithms.py", line 25, in 
                  import gdalnumeric
                  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
                  mod = _builtin_import(name, globals, locals, fromlist, level)
                 ModuleNotFoundError: No module named 'gdalnumeric'
    

    Maybe you want to transfer this to another issue.

  10. Helge Daempfling

    @Augustin Lobo

    If you want to run the newest version that I recently committed to run on Linux you must changes the following lines in the according files:

    in enmap-box/enmapbox/apps/engeomap/algorithms.py:

    the line from osgeo import gdalnumeric back to import gdalnumeric

    in enmap-box/enmapbox/apps/engeomap/engeomap_aux_funcul.py:

    the line from osgeo import gdal back to import gdal

    and the line from osgeo import gdalnumeric back to import gdalnumeric

    This should allow it to run the newest development branch under Linux.

    I will try to write an OS function that imports GDAL according to the OS used. Actually I believe this should then make EnGeoMAP run under Linux or Debian/Mac OS as well.

  11. Fabian Thiel

    Maybe this already does the trick

    try:
        from osgeo import gdal
    except ImportError:
        import gdal
    

  12. Agustin Lobo reporter

    in enmap-box/enmapbox/apps/engeomap/algorithms.py:

    the line from osgeo import gdalnumeric back to import gdalnumeric

    in enmap-box/enmapbox/apps/engeomap/engeomap_aux_funcul.py:

    the line from osgeo import gdal back to import gdal

    and the line from osgeo import gdalnumeric back to import gdalnumeric

    This is as I have it, nothing to change:

    algorithms.py

    engeomap_aux_funcul.py:

    2022-05-16T16:10:02     WARNING    Python error : An error has occurred while executing Python code: See message log (Python Error) for more details.
    
    2022-05-16T16:10:02     WARNING    Traceback (most recent call last):
                  File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/apps/engeomap/userinterfaces.py", line 124, in startAlgorithm
                  from engeomap.algorithms import engeomapp_headless
                  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
                  mod = _builtin_import(name, globals, locals, fromlist, level)
                  File "/home/alobo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/apps/engeomap/algorithms.py", line 25, in 
                  import gdalnumeric
                  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
                  mod = _builtin_import(name, globals, locals, fromlist, level)
                 ModuleNotFoundError: No module named 'gdalnumeric'
    

    Version 3.10.0.20220401T124144.develop c7d679b

  13. Helge Daempfling

    Ok, hm I don’t know why gdalnumeric isn’t correctly imported on your machine.

    Have you tried it the other way round as I suggested?

    ( from osgeo import gdalnumeric and

    from osgeo import gdal)

    Edit: found out why:

    https://gis.stackexchange.com/questions/393212/import-gdal-vs-import-osgeo-gdal

    import gdalnumeric

    and import gdal was entirely removed in the gdal version you are using.

    Now also Linux uses the import as I changed it in the last commit

    from osgeo import gdalnumeric

    from osgeo import gdal

    if you get the newest commit or change these lines in the files I mentioned before( just the other way round) it should work on your machine.

    Kind Regards,

    Helge

  14. Log in to comment