bauerdavid / napari-nD-annotator

BSD 3-Clause "New" or "Revised" License
29 stars 2 forks source link

Error when installing in napari 0.5.0 #51

Open Alecampoy opened 4 months ago

Alecampoy commented 4 months ago

Hi when I install the annotator I obtain the following error using napari 0.5.0 and python 3.12 everything installed with pip. Is there a problem with versions?

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File ~\napari_venv\Lib\site-packages\npe2\_command_registry.py:32, in CommandHandler.resolve(self=CommandHandler(id='napari-nD-annotator.annotator...ython_name='napari_nd_annotator:AnnotatorWidget'))
     31 try:
---> 32     self.function = utils.import_python_name(self.python_name)
        self.function = None
        self.python_name = 'napari_nd_annotator:AnnotatorWidget'
        self = CommandHandler(id='napari-nD-annotator.annotator_widget', function=None, python_name='napari_nd_annotator:AnnotatorWidget')
        utils = <module 'npe2.manifest.utils' from 'C:\\Users\\Ale Campoy\\napari_venv\\Lib\\site-packages\\npe2\\manifest\\utils.py'>
     33 except Exception as e:

File ~\napari_venv\Lib\site-packages\npe2\manifest\utils.py:254, in import_python_name(python_name='napari_nd_annotator:AnnotatorWidget')
    252 module_name, funcname = match.groups()  # type: ignore [union-attr]
--> 254 mod = import_module(module_name)
        module_name = 'napari_nd_annotator'
    255 return getattr(mod, funcname)

File C:\Program Files\Python312\Lib\importlib\__init__.py:90, in import_module(name='napari_nd_annotator', package=None)
     89         level += 1
---> 90 return _bootstrap._gcd_import(name[level:], package, level)
        level = 0
        name = 'napari_nd_annotator'
        name[level:] = 'napari_nd_annotator'
        package = None
        _bootstrap = <module '_frozen_importlib' (frozen)>

File <frozen importlib._bootstrap>:1387, in _gcd_import(name='napari_nd_annotator', package=None, level=0)

File <frozen importlib._bootstrap>:1360, in _find_and_load(name='napari_nd_annotator', import_=<function _gcd_import>)

File <frozen importlib._bootstrap>:1331, in _find_and_load_unlocked(name='napari_nd_annotator', import_=<function _gcd_import>)

File <frozen importlib._bootstrap>:935, in _load_unlocked(spec=ModuleSpec(name='napari_nd_annotator', loader=<_..._venv\\Lib\\site-packages\\napari_nd_annotator']))

File <frozen importlib._bootstrap_external>:994, in exec_module(self=<_frozen_importlib_external.SourceFileLoader object>, module=<module 'napari_nd_annotator' from 'C:\\Users\\A...site-packages\\napari_nd_annotator\\__init__.py'>)

File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f=<built-in function exec>, *args=(<code object <module> at 0x000001BCBBDB4B70, fil...ackages\napari_nd_annotator\__init__.py", line 1>, {'__builtins__': {'ArithmeticError': <class 'ArithmeticError'>, 'AssertionError': <class 'AssertionError'>, 'AttributeError': <class 'AttributeError'>, 'BaseException': <class 'BaseException'>, 'BaseExceptionGroup': <class 'BaseExceptionGroup'>, 'BlockingIOError': <class 'BlockingIOError'>, 'BrokenPipeError': <class 'BrokenPipeError'>, 'BufferError': <class 'BufferError'>, 'BytesWarning': <class 'BytesWarning'>, 'ChildProcessError': <class 'ChildProcessError'>, ...}, '__cached__': r'C:\Users\Ale Campoy\napari_venv\Lib\site-package...nd_annotator\__pycache__\__init__.cpython-312.pyc', '__doc__': None, '__file__': r'C:\Users\Ale Campoy\napari_venv\Lib\site-packages\napari_nd_annotator\__init__.py', '__loader__': <_frozen_importlib_external.SourceFileLoader object>, '__name__': 'napari_nd_annotator', '__package__': 'napari_nd_annotator', '__path__': [r'C:\Users\Ale Campoy\napari_venv\Lib\site-packages\napari_nd_annotator'], '__spec__': ModuleSpec(name='napari_nd_annotator', loader=<_..._venv\\Lib\\site-packages\\napari_nd_annotator']), '__version__': '0.2.3', ...}), **kwds={})

File ~\napari_venv\Lib\site-packages\napari_nd_annotator\__init__.py:4
      2 __version__ = "0.2.3"
----> 4 from ._widgets import AnnotatorWidget, InterpolationWidget, MinimalSurfaceWidget
      5 from packaging import version

File ~\napari_venv\Lib\site-packages\napari_nd_annotator\_widgets\__init__.py:1
----> 1 from .interpolation_widget import InterpolationWidget
      2 from .projections import SliceDisplayWidget

File ~\napari_venv\Lib\site-packages\napari_nd_annotator\_widgets\interpolation_widget.py:17
     16 from napari_nd_annotator._widgets._utils.persistence import PersistentWidget
---> 17 from ..mean_contour import settings
     18 from ..mean_contour.meanContour import MeanThread

File ~\napari_venv\Lib\site-packages\napari_nd_annotator\mean_contour\settings.py:2
      1 import json
----> 2 from .util import getReconMethod
      4 class Settings:

File ~\napari_venv\Lib\site-packages\napari_nd_annotator\mean_contour\util.py:2
      1 import numpy as np
----> 2 from ._essentials import ReconstructionMethods, Contour
      3 import matplotlib.pyplot as plt

File src\\napari_nd_annotator\\mean_contour\\cEssentialscy.pyx:1, in init napari_nd_annotator.mean_contour._essentials()

ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use '<void>numpy._import_array' to disable if you are certain you don't need it).

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
File ~\napari_venv\Lib\site-packages\app_model\backends\qt\_qaction.py:55, in QCommandAction._on_triggered(self=QMenuItemAction(MenuItem(when=None, group='3_plu...Annotation Toolbox)'))), alt=None), app='napari'), checked=True)
     51 def _on_triggered(self, checked: bool) -> None:
     52     # execute_command returns a Future, for the sake of eventually being
     53     # asynchronous without breaking the API.  For now, we call result()
     54     # to raise any exceptions.
---> 55     self._app.commands.execute_command(self._command_id).result()
        self._command_id = 'napari-nD-annotator:Annotation Toolbox'
        self = QMenuItemAction(MenuItem(when=None, group='3_plugin_contributions', order=None, command=CommandRule(id='napari-nD-annotator:Annotation Toolbox', title='Annotation Toolbox', category=None, tooltip=None, status_tip=None, icon=None, icon_visible_in_menu=True, enablement=None, short_title=None, toggled=ToggleRule(condition=None, get_current=functools.partial(<function _get_current_dock_status at 0x000001BCB077FB00>, full_name='Annotation Toolbox (Annotation Toolbox)'))), alt=None), app='napari')
        self._app = Application('napari')

File ~\napari_venv\Lib\site-packages\app_model\registries\_commands_reg.py:245, in CommandsRegistry.execute_command(self=<CommandsRegistry at 0x1bcb07aa360 (143 commands)>, id='napari-nD-annotator:Annotation Toolbox', execute_asynchronously=False, *args=(), **kwargs={})
    241 except Exception as e:
    242     if self._raise_synchronous_exceptions:
    243         # note, the caller of this function can also achieve this by
    244         # calling `future.result()` on the returned future object.
--> 245         raise e
    246     future.set_exception(e)
    248 return future

File ~\napari_venv\Lib\site-packages\app_model\registries\_commands_reg.py:240, in CommandsRegistry.execute_command(self=<CommandsRegistry at 0x1bcb07aa360 (143 commands)>, id='napari-nD-annotator:Annotation Toolbox', execute_asynchronously=False, *args=(), **kwargs={})
    238 future: Future = Future()
    239 try:
--> 240     future.set_result(cmd(*args, **kwargs))
        future = <Future at 0x1bcbce395e0 state=pending>
        cmd = <function Store.inject.<locals>._inner.<locals>._exec at 0x000001BCBCE2D8A0>
        args = ()
        kwargs = {}
    241 except Exception as e:
    242     if self._raise_synchronous_exceptions:
    243         # note, the caller of this function can also achieve this by
    244         # calling `future.result()` on the returned future object.

File ~\napari_venv\Lib\site-packages\in_n_out\_store.py:934, in Store.inject_processors.<locals>._deco.<locals>._exec(*args=(), **kwargs={})
    932 @wraps(func)
    933 def _exec(*args: P.args, **kwargs: P.kwargs) -> R:
--> 934     result = func(*args, **kwargs)
        func = <function Store.inject.<locals>._inner.<locals>._exec at 0x000001BCBCE2D760>
        args = ()
        kwargs = {}
    935     if result is not None:
    936         self.process(
    937             result,
    938             type_hint=type_hint,
   (...)
    941             _funcname=getattr(func, "__qualname__", str(func)),
    942         )

File ~\napari_venv\Lib\site-packages\in_n_out\_store.py:804, in Store.inject.<locals>._inner.<locals>._exec(*args=(), **kwargs={})
    797 logger.debug(
    798     "  Calling %s with %r (injected %r)",
    799     _fname,
    800     bound.arguments,
    801     _injected_names,
    802 )
    803 try:
--> 804     result = func(**bound.arguments)
        bound = <BoundArguments (plugin='napari-nD-annotator', widget_name='Annotation Toolbox', full_name='Annotation Toolbox (Annotation Toolbox)')>
        func = functools.partial(<function _toggle_or_get_widget at 0x000001BCB077FA60>, plugin='napari-nD-annotator', widget_name='Annotation Toolbox', full_name='Annotation Toolbox (Annotation Toolbox)')
        bound.arguments = {'plugin': 'napari-nD-annotator', 'widget_name': 'Annotation Toolbox', 'full_name': 'Annotation Toolbox (Annotation Toolbox)'}
    805 except TypeError as e:
    806     if "missing" not in e.args[0]:

File ~\napari_venv\Lib\site-packages\napari\_qt\_qplugins\_qnpe2.py:344, in _toggle_or_get_widget(plugin='napari-nD-annotator', widget_name='Annotation Toolbox', full_name='Annotation Toolbox (Annotation Toolbox)')
    341     return None
    343 # Get widget param name (if any) and check type
--> 344 widget_callable, _ = get_widget_contribution(plugin, widget_name)  # type: ignore [misc]
        plugin = 'napari-nD-annotator'
        widget_name = 'Annotation Toolbox'
    345 widget_param = _get_widget_viewer_param(widget_callable, widget_name)
    347 kwargs = {}

File ~\napari_venv\Lib\site-packages\napari\plugins\_npe2.py:130, in get_widget_contribution(plugin_name='napari-nD-annotator', widget_name='Annotation Toolbox')
    128     if contrib.plugin_name == plugin_name:
    129         if not widget_name or contrib.display_name == widget_name:
--> 130             return contrib.get_callable(), contrib.display_name
        contrib = WidgetContribution(command='napari-nD-annotator.annotator_widget', display_name='Annotation Toolbox', autogenerate=False)
        contrib.display_name = 'Annotation Toolbox'
    131         widgets_seen.add(contrib.display_name)
    132 if widget_name and widgets_seen:

File ~\napari_venv\Lib\site-packages\npe2\manifest\contributions\_widgets.py:49, in WidgetContribution.get_callable(self=WidgetContribution(command='napari-nD-annotator....ay_name='Annotation Toolbox', autogenerate=False), _registry=None)
     46 def get_callable(
     47     self, _registry: Optional[CommandRegistry] = None
     48 ) -> Callable[..., Widget]:
---> 49     func = super().get_callable()
     50     if self.autogenerate:
     51         try:

File ~\napari_venv\Lib\site-packages\npe2\manifest\utils.py:71, in Executable.get_callable(self=WidgetContribution(command='napari-nD-annotator....ay_name='Annotation Toolbox', autogenerate=False), _registry=<npe2._command_registry.CommandRegistry object>)
     68     from npe2._plugin_manager import PluginManager
     70     _registry = PluginManager.instance().commands
---> 71 return _registry.get(self.command)
        _registry = <npe2._command_registry.CommandRegistry object at 0x000001BCAC6C9940>
        self.command = 'napari-nD-annotator.annotator_widget'
        self = WidgetContribution(command='napari-nD-annotator.annotator_widget', display_name='Annotation Toolbox', autogenerate=False)

File ~\napari_venv\Lib\site-packages\npe2\_command_registry.py:138, in CommandRegistry.get(self=<npe2._command_registry.CommandRegistry object>, id='napari-nD-annotator.annotator_widget')
    136     if id not in self._commands:  # sourcery skip
    137         raise KeyError(f"command {id!r} not registered")
--> 138 return self._commands[id].resolve()
        id = 'napari-nD-annotator.annotator_widget'
        self._commands = {'napari-nD-annotator.annotator_widget': CommandHandler(id='napari-nD-annotator.annotator_widget', function=None, python_name='napari_nd_annotator:AnnotatorWidget'), 'napari-nD-annotator.interpolation_widget': CommandHandler(id='napari-nD-annotator.interpolation_widget', function=None, python_name='napari_nd_annotator:InterpolationWidget'), 'napari-nD-annotator.object_list_widget': CommandHandler(id='napari-nD-annotator.object_list_widget', function=None, python_name='napari_nd_annotator:ListWidgetBB')}
        self = <npe2._command_registry.CommandRegistry object at 0x000001BCAC6C9940>
        self._commands[id] = CommandHandler(id='napari-nD-annotator.annotator_widget', function=None, python_name='napari_nd_annotator:AnnotatorWidget')

File ~\napari_venv\Lib\site-packages\npe2\_command_registry.py:34, in CommandHandler.resolve(self=CommandHandler(id='napari-nD-annotator.annotator...ython_name='napari_nd_annotator:AnnotatorWidget'))
     32     self.function = utils.import_python_name(self.python_name)
     33 except Exception as e:
---> 34     raise RuntimeError(
        self.python_name = 'napari_nd_annotator:AnnotatorWidget'
        self = CommandHandler(id='napari-nD-annotator.annotator_widget', function=None, python_name='napari_nd_annotator:AnnotatorWidget')
     35         f"Failed to import command at {self.python_name!r}: {e}"
     36     ) from e
     38 return self.function

RuntimeError: Failed to import command at 'napari_nd_annotator:AnnotatorWidget': numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use '<void>numpy._import_array' to disable if you are certain you don't need it).

napari info napari: 0.5.0 Platform: Windows-11-10.0.22631-SP0 Python: 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] Qt: 5.15.2 PyQt5: 5.15.11 NumPy: 2.0.1 SciPy: 1.14.0 Dask: 2024.7.1 VisPy: 0.14.3 magicgui: 0.8.3 superqt: 0.6.7 in-n-out: 0.2.1 app-model: 0.2.8 npe2: 0.7.6

OpenGL:

bauerdavid commented 3 months ago

Hey @Alecampoy, the plugin currently doesn't work with numpy>=2 and napari>=0.5. Try downgrading them (to "numpy<2" "napari<0.5"). Reach out if it doesn't solve your problem.

Cheers!

Alecampoy commented 3 months ago

thank you! could you please provide an already tested versions set that you know works? I tried Napari 0.4.16 with python 3.10 and also got an error. It would be great to create an environment that is tested. best wishes!

bauerdavid commented 3 months ago

Did you also downgrade numpy version? Could you provide the error message?

Alecampoy commented 3 months ago

Sorry I deleted the environment, with those versions simply napari without the annotator didn't work, so I guess it's on my side and the wrong coding of versions. A working requirements.txt file of a working environment and specific python version would be much appreciated

-------- Mensaje original -------- El 29/7/24 14:18, Dávid Bauer ha escrito:

Did you also downgrade numpy version? Could you provide the error message?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

bauerdavid commented 3 months ago

I've created an env from scratch (Python 3.12), this was working for me. Check it out whether it works for you. requirements.txt

bauerdavid commented 3 months ago

It seems I managed to make it work for the newest napari version. I'll create a release soon, until then you can try it from the repo.

Alecampoy commented 3 months ago

Thank you for the requirements.txt. Unfortunately trying to install it also generates few errors and one of them I am unable to solve. The listed version of vispy==0.12.2 (necesarry with the nympy 0.4) is not able to compile when installing IDK why. I already had updated Visual C++ and with it, vispy==0.14 installs without issues. I wait till you have the new release ready.

El jueves, 1 de agosto de 2024 a las 11:59, Dávid Bauer @.***> escribió:

I've created an env from scratch (Python 3.12), this was working for me. Check it out whether it works for you. requirements.txt

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>