EnMAP-Box / enmap-box

EnMAP-Box source code repository. See https://enmap-box.readthedocs.io for documentation
GNU General Public License v3.0
35 stars 16 forks source link

AttributeError: module 'numpy' has no attribute 'float' #510

Closed jakimowb closed 5 months ago

jakimowb commented 1 year ago

The following error is raqised when:

  1. Opening ENMAP01-____L2A-DT0000001867_20220724T104526Z_008_V010111_20230213T084607Z-SPECTRAL_IMAGE.TIF
  2. Adding the image to a map view
  3. Right-clicking the created layer in the Data View panel

This makes it impossible to open the layer property attributes.

AttributeError: module 'numpy' has no attribute 'float' 
Traceback (most recent call last):
  File "C:\Users/geo_beja/AppData/Roaming/QGIS/QGIS3\profiles\enmapbox_dev/python/plugins\enmapboxplugin\enmapbox\gui\dataviews\dockmanager.py", line 1597, in createContextMenu
    self.addRasterLayerMenuItems(node, menu)
  File "C:\Users/geo_beja/AppData/Roaming/QGIS/QGIS3\profiles\enmapbox_dev/python/plugins\enmapboxplugin\enmapbox\gui\dataviews\dockmanager.py", line 1749, in addRasterLayerMenuItems
    from bivariatecolorrasterrendererapp import BivariateColorRasterRendererApp
  File "F:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\Users\geo_beja\AppData\Roaming\QGIS\QGIS3\profiles\enmapbox_dev\python\plugins\enmapboxplugin\enmapbox\coreapps\bivariatecolorrasterrendererapp\__init__.py", line 1, in 
    from bivariatecolorrasterrendererapp.bivariatecolorrasterrendererdialog import BivariateColorRasterRendererDialog
  File "F:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\Users\geo_beja\AppData\Roaming\QGIS\QGIS3\profiles\enmapbox_dev\python\plugins\enmapboxplugin\enmapbox\coreapps\bivariatecolorrasterrendererapp\bivariatecolorrasterrendererdialog.py", line 6, in 
    from bivariatecolorrasterrendererapp.bivariatecolorrasterrenderer import BivariateColorRasterRenderer
  File "F:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\Users\geo_beja\AppData\Roaming\QGIS\QGIS3\profiles\enmapbox_dev\python\plugins\enmapboxplugin\enmapbox\coreapps\bivariatecolorrasterrendererapp\bivariatecolorrasterrenderer.py", line 9, in 
    from sklearn.decomposition import PCA
  File "F:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "F:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\decomposition\__init__.py", line 17, in 
    from .dict_learning import dict_learning
  File "F:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "F:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\decomposition\dict_learning.py", line 5, in 
    from . import _dict_learning  # type: ignore
  File "F:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "F:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\decomposition\_dict_learning.py", line 21, in 
    from ..linear_model import Lasso, orthogonal_mp_gram, LassoLars, Lars
  File "F:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "F:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\linear_model\__init__.py", line 11, in 
    from ._least_angle import (Lars, LassoLars, lars_path, lars_path_gram, LarsCV,
  File "F:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "F:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\linear_model\_least_angle.py", line 34, in 
    method='lar', copy_X=True, eps=np.finfo(np.float).eps,
  File "F:\OSGeo4W\apps\Python39\lib\site-packages\numpy\__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float'
janzandr commented 1 year ago

Can't reproduce this on QGIS LTR 3.28.7. What is your version?

janzandr commented 1 year ago

Problem is related to your sklearn: image

janzandr commented 1 year ago

Try to import this: from sklearn.decomposition import PCA Is that working?

jakimowb commented 1 year ago

Indeed, seems to be caused by the standard OSGeo4W sklearn version. Nevertheless, an attempt to open a context menue should never crash the EnMAP-Box because of this.

janzandr commented 1 year ago

The sklearn import is already wrapped with a try-except block: image

janzandr commented 1 year ago

As a quick fix, before we have #513, shall we have try-excepts around every entry, here? image

jakimowb commented 5 months ago

relates to https://trac.osgeo.org/osgeo4w/ticket/823