Error when installing in napari 0.5.0
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:
- GL version: 4.6.0 - Build 27.20.100.8681
- MAX_TEXTURE_SIZE: 16384
- GL_MAX_3D_TEXTURE_SIZE: 2048
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!
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!
Did you also downgrade numpy version? Could you provide the error message?
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: @.***>
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
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.
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: @.***>
Just wanted to report that the plugin does not work with napari 0.5.6 as napari-bbox interface does not open I've successfully managed to run it (Fedora 39) with
napari==0.5.4 napari-bbox @ git+https://github.com/bauerdavid/napari-bbox.git@b6f5fd5655566795fa903416de3fee6f8cdf9101 napari-nD-annotator @ git+https://github.com/bauerdavid/napari-nD-annotator.git@6582935dd3a91c12cabbb9763364cf7e8e83c642 numpy==2.2.2
Attached a requirements.txt file
A couple of points:
- I see 3 entries in the menu "Annotation Toolbox", "Slice Interpolator" and "Object List". Slice Interpolator seems to be a partial duplicate of Annotation Toolbox, but pressing Annotate there results in
AttributeError: 'InterpolationWidget' object has no attribute '_viewer'Otherwise, the other widget works.
- When opening the Annotation Toolbox four locked layers get created (see screenshot). I'm not sure if that are supposed to be there or not, but they don't seem to hinder the annotation process in any case.
I created an env with the provided requirements.txt and python 3.12, but the error showed up "TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'". Any suggestion?
Hey @nicolaromano ,
- You are right, the interpolate widget is a duplicate, so the most simple solution is to remove it, and make it work only within the Annotation Toolbox widget. (I think I exposed it initially because there was no clear design idea on how to expose functionality... I was young and reckless 🤷) Just to make sure I understand correctly: You get the error message above only when trying to use the "standalone" interpolate widget (not integrated into the Annotation Toolbox widget)? Does it work correctly anyway?
- This is an intented thing, as these layers store intermediate results for the minimal contour tool. Believe it or not, but I just started to work on removing those extra layers and use highlights instead, see my question here.
Could you post the complete error message along with napari info, and plugin versions (napari-bbox and napari-nD-annotator)? Did you use the newest version of both?
Please open a separate issue, as this seems to be a completely different problem.
I created an env with the provided requirements.txt and python 3.12, but the error showed up "TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'". Any suggestion?
@MingxuanGu please open a separate issue, this seems to be a different problem. Would you mind adding napari info, the complete error message and plugin versions there, please?
Hi there
I couldn't make the annotator to work with any of the requirements files shared here. It was a bit frustrating, cause there are many conflicts with versions in several packages.
If there is of any help for someone, here requirements.txt I got it working with python 3.10.4 on Ubuntu 24.04