ImportError: DLL load failed while importing _nifty: Das angegebene Modul wurde nicht gefunden
Dear all,
as I could not get Micro-Sam to work with the Windows-Installer, I tried again with Mamba. However, now I get the following error:
Failed to import command at 'micro_sam.sam_annotator.annotator_2d:Annotator2d': DLL load failed while importing _nifty: Das angegebene Modul wurde nicht gefunden.
Traceback below.
Thanks and best Matthias
ImportError Traceback (most recent call last) File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\npe2_command_registry.py:32, in CommandHandler.resolve(self=CommandHandler(id='micro-sam.annotator_2d', func...icro_sam.sam_annotator.annotator_2d:Annotator2d')) 31 try: ---> 32 self.function = utils.import_python_name(self.python_name) self.function = None self.python_name = 'micro_sam.sam_annotator.annotator_2d:Annotator2d' self = CommandHandler(id='micro-sam.annotator_2d', function=None, python_name='micro_sam.sam_annotator.annotator_2d:Annotator2d') utils = <module 'npe2.manifest.utils' from 'C:\Users\kirsch\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\npe2\manifest\utils.py'> 33 except Exception as e:
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\npe2\manifest\utils.py:254, in import_python_name(python_name='micro_sam.sam_annotator.annotator_2d:Annotator2d') 252 module_name, funcname = match.groups() # type: ignore [union-attr] --> 254 mod = import_module(module_name) module_name = 'micro_sam.sam_annotator.annotator_2d' 255 return getattr(mod, funcname)
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\importlib_init_.py:90, in import_module(name='micro_sam.sam_annotator.annotator_2d', package=None) 89 level += 1 ---> 90 return _bootstrap._gcd_import(name[level:], package, level) level = 0 name = 'micro_sam.sam_annotator.annotator_2d' name[level:] = 'micro_sam.sam_annotator.annotator_2d' package = None _bootstrap = <module '_frozen_importlib' (frozen)>
File
File
File
File
File
File
File
File
File
File
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\micro_sam\sam_annotator_init_.py:4 1 """The interactive annotation tools. 2 """ ----> 4 from .annotator_2d import annotator_2d 5 from .annotator_3d import annotator_3d
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\micro_sam\sam_annotator\annotator_2d.py:7 5 import torch ----> 7 from . import _widgets as widgets 8 from ._annotator import _AnnotatorBase
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\micro_sam\sam_annotator_widgets.py:11 9 from typing import Optional ---> 11 import elf.parallel 12 import h5py
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\elf\parallel_init_.py:1 ----> 1 from .copy_dataset import copy_dataset 2 from .distance_transform import distance_transform
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\elf\parallel\copy_dataset.py:5 4 from tqdm import tqdm ----> 5 from .common import get_blocking 8 def copy_dataset(ds_in, ds_out, 9 roi_in=None, 10 roi_out=None, 11 block_shape=None, 12 n_threads=None, 13 verbose=False):
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\elf\parallel\common.py:1 ----> 1 import nifty.tools as nt 2 from ..util import normalize_index
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\nifty_init_.py:4 2 from future import print_function ----> 4 from ._nifty import * 6 import types
ImportError: DLL load failed while importing _nifty: Das angegebene Modul wurde nicht gefunden.
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last) File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\app_model\backends\qt_qaction.py:55, in QCommandAction._on_triggered(self=QMenuItemAction(MenuItem(when=None, group='3_plu...ing for Microscopy)'))), 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 = 'micro-sam:Annotator 2d' self = QMenuItemAction(MenuItem(when=None, group='3_plugin_contributions', order=None, command=CommandRule(id='micro-sam:Annotator 2d', title='Annotator 2d', 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 0x0000022D54096840>, full_name='Annotator 2d (SegmentAnything for Microscopy)'))), alt=None), app='napari') self._app = Application('napari')
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\app_model\registries_commands_reg.py:245, in CommandsRegistry.execute_command(self=<CommandsRegistry at 0x22d5403a180 (153 commands)>, id='micro-sam:Annotator 2d', 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 ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\app_model\registries_commands_reg.py:240, in CommandsRegistry.execute_command(self=<CommandsRegistry at 0x22d5403a180 (153 commands)>, id='micro-sam:Annotator 2d', execute_asynchronously=False, *args=(), **kwargs={})
238 future: Future = Future()
239 try:
--> 240 future.set_result(cmd(*args, **kwargs))
future = <Future at 0x22d784ab740 state=pending>
cmd = <function Store.inject.future.result() on the returned future object.
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\in_n_out_store.py:934, in Store.inject_processors.
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\in_n_out_store.py:804, in Store.inject.
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\napari_qt_qplugins_qnpe2.py:344, in _toggle_or_get_widget(plugin='micro-sam', widget_name='Annotator 2d', full_name='Annotator 2d (SegmentAnything for Microscopy)') 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 = 'micro-sam' widget_name = 'Annotator 2d' 345 widget_param = _get_widget_viewer_param(widget_callable, widget_name) 347 kwargs = {}
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\napari\plugins_npe2.py:130, in get_widget_contribution(plugin_name='micro-sam', widget_name='Annotator 2d') 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='micro-sam.annotator_2d', display_name='Annotator 2d', autogenerate=False) contrib.display_name = 'Annotator 2d' 131 widgets_seen.add(contrib.display_name) 132 if widget_name and widgets_seen:
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\npe2\manifest\contributions_widgets.py:49, in WidgetContribution.get_callable(self=WidgetContribution(command='micro-sam.annotator_... display_name='Annotator 2d', 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 ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\npe2\manifest\utils.py:71, in Executable.get_callable(self=WidgetContribution(command='micro-sam.annotator_... display_name='Annotator 2d', 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 0x0000022D504FD580> self.command = 'micro-sam.annotator_2d' self = WidgetContribution(command='micro-sam.annotator_2d', display_name='Annotator 2d', autogenerate=False)
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\npe2_command_registry.py:138, in CommandRegistry.get(self=<npe2._command_registry.CommandRegistry object>, id='micro-sam.annotator_2d') 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 = 'micro-sam.annotator_2d' self._commands = {'napari.get_reader': CommandHandler(id='napari.get_reader', function=<function napari_get_reader at 0x0000022D53F53380>, python_name='napari_builtins.io:napari_get_reader'), 'napari.write_image': CommandHandler(id='napari.write_image', function=None, python_name='napari_builtins.io:napari_write_image'), 'napari.write_labels': CommandHandler(id='napari.write_labels', function=None, python_name='napari_builtins.io:napari_write_labels'), 'napari.write_points': CommandHandler(id='napari.write_points', function=None, python_name='napari_builtins.io:napari_write_points'), 'napari.write_shapes': CommandHandler(id='napari.write_shapes', function=None, python_name='napari_builtins.io:napari_write_shapes'), 'napari.write_directory': CommandHandler(id='napari.write_directory', function=None, python_name='napari_builtins.io:write_layer_data_with_plugins'), 'napari.data.astronaut': CommandHandler(id='napari.data.astronaut', function=None, python_name='napari_builtins._skimage_data:astronaut'), 'napari.data.binary_blobs': CommandHandler(id='napari.data.binary_blobs', function=None, python_name='napari_builtins._skimage_data:binary_blobs'), 'napari.data.binary_blobs_3D': CommandHandler(id='napari.data.binary_blobs_3D', function=None, python_name='napari_builtins._skimage_data:binary_blobs_3D'), 'napari.data.brain': CommandHandler(id='napari.data.brain', function=None, python_name='napari_builtins._skimage_data:brain'), 'napari.data.brick': CommandHandler(id='napari.data.brick', function=None, python_name='napari_builtins._skimage_data:brick'), 'napari.data.camera': CommandHandler(id='napari.data.camera', function=None, python_name='napari_builtins._skimage_data:camera'), 'napari.data.cat': CommandHandler(id='napari.data.cat', function=None, python_name='napari_builtins._skimage_data:cat'), 'napari.data.cell': CommandHandler(id='napari.data.cell', function=None, python_name='napari_builtins._skimage_data:cell'), 'napari.data.cells3d': CommandHandler(id='napari.data.cells3d', function=None, python_name='napari_builtins._skimage_data:cells3d'), 'napari.data.checkerboard': CommandHandler(id='napari.data.checkerboard', function=None, python_name='napari_builtins._skimage_data:checkerboard'), 'napari.data.clock': CommandHandler(id='napari.data.clock', function=None, python_name='napari_builtins._skimage_data:clock'), 'napari.data.coffee': CommandHandler(id='napari.data.coffee', function=None, python_name='napari_builtins._skimage_data:coffee'), 'napari.data.coins': CommandHandler(id='napari.data.coins', function=None, python_name='napari_builtins._skimage_data:coins'), 'napari.data.colorwheel': CommandHandler(id='napari.data.colorwheel', function=None, python_name='napari_builtins._skimage_data:colorwheel'), 'napari.data.eagle': CommandHandler(id='napari.data.eagle', function=None, python_name='napari_builtins._skimage_data:eagle'), 'napari.data.grass': CommandHandler(id='napari.data.grass', function=None, python_name='napari_builtins._skimage_data:grass'), 'napari.data.gravel': CommandHandler(id='napari.data.gravel', function=None, python_name='napari_builtins._skimage_data:gravel'), 'napari.data.horse': CommandHandler(id='napari.data.horse', function=None, python_name='napari_builtins._skimage_data:horse'), 'napari.data.hubble_deep_field': CommandHandler(id='napari.data.hubble_deep_field', function=None, python_name='napari_builtins._skimage_data:hubble_deep_field'), 'napari.data.human_mitosis': CommandHandler(id='napari.data.human_mitosis', function=None, python_name='napari_builtins._skimage_data:human_mitosis'), 'napari.data.immunohistochemistry': CommandHandler(id='napari.data.immunohistochemistry', function=None, python_name='napari_builtins._skimage_data:immunohistochemistry'), 'napari.data.kidney': CommandHandler(id='napari.data.kidney', function=None, python_name='napari_builtins._skimage_data:kidney'), 'napari.data.lfw_subset': CommandHandler(id='napari.data.lfw_subset', function=None, python_name='napari_builtins._skimage_data:lfw_subset'), 'napari.data.lily': CommandHandler(id='napari.data.lily', function=None, python_name='napari_builtins._skimage_data:lily'), 'napari.data.microaneurysms': CommandHandler(id='napari.data.microaneurysms', function=None, python_name='napari_builtins._skimage_data:microaneurysms'), 'napari.data.moon': CommandHandler(id='napari.data.moon', function=None, python_name='napari_builtins._skimage_data:moon'), 'napari.data.page': CommandHandler(id='napari.data.page', function=None, python_name='napari_builtins._skimage_data:page'), 'napari.data.retina': CommandHandler(id='napari.data.retina', function=None, python_name='napari_builtins._skimage_data:retina'), 'napari.data.rocket': CommandHandler(id='napari.data.rocket', function=None, python_name='napari_builtins._skimage_data:rocket'), 'napari.data.shepp_logan_phantom': CommandHandler(id='napari.data.shepp_logan_phantom', function=None, python_name='napari_builtins._skimage_data:shepp_logan_phantom'), 'napari.data.skin': CommandHandler(id='napari.data.skin', function=None, python_name='napari_builtins._skimage_data:skin'), 'napari.data.text': CommandHandler(id='napari.data.text', function=None, python_name='napari_builtins._skimage_data:text'), 'napari.data.balls_2d': CommandHandler(id='napari.data.balls_2d', function=None, python_name='napari_builtins._ndims_balls:labeled_particles2d'), 'napari.data.balls_3d': CommandHandler(id='napari.data.balls_3d', function=None, python_name='napari_builtins._ndims_balls:labeled_particles3d'), 'micro-sam.sample_data_wholeslide': CommandHandler(id='micro-sam.sample_data_wholeslide', function=None, python_name='micro_sam.sample_data:sample_data_wholeslide'), 'micro-sam.sample_data_livecell': CommandHandler(id='micro-sam.sample_data_livecell', function=None, python_name='micro_sam.sample_data:sample_data_livecell'), 'micro-sam.sample_data_hela_2d': CommandHandler(id='micro-sam.sample_data_hela_2d', function=None, python_name='micro_sam.sample_data:sample_data_hela_2d'), 'micro-sam.sample_data_3d': CommandHandler(id='micro-sam.sample_data_3d', function=None, python_name='micro_sam.sample_data:sample_data_3d'), 'micro-sam.sample_data_tracking': CommandHandler(id='micro-sam.sample_data_tracking', function=None, python_name='micro_sam.sample_data:sample_data_tracking'), 'micro-sam.sample_data_segmentation': CommandHandler(id='micro-sam.sample_data_segmentation', function=None, python_name='micro_sam.sample_data:sample_data_segmentation'), 'micro-sam.annotator_2d': CommandHandler(id='micro-sam.annotator_2d', function=None, python_name='micro_sam.sam_annotator.annotator_2d:Annotator2d'), 'micro-sam.annotator_3d': CommandHandler(id='micro-sam.annotator_3d', function=None, python_name='micro_sam.sam_annotator.annotator_3d:Annotator3d'), 'micro-sam.annotator_tracking': CommandHandler(id='micro-sam.annotator_tracking', function=None, python_name='micro_sam.sam_annotator.annotator_tracking:AnnotatorTracking'), 'micro-sam.image_series_annotator': CommandHandler(id='micro-sam.image_series_annotator', function=None, python_name='micro_sam.sam_annotator.image_series_annotator:ImageSeriesAnnotator'), 'micro-sam.training': CommandHandler(id='micro-sam.training', function=None, python_name='micro_sam.sam_annotator.training_ui:TrainingWidget'), 'micro-sam.settings': CommandHandler(id='micro-sam.settings', function=None, python_name='micro_sam.sam_annotator._widgets:settings_widget')} self = <npe2._command_registry.CommandRegistry object at 0x0000022D504FD580> self._commands[id] = CommandHandler(id='micro-sam.annotator_2d', function=None, python_name='micro_sam.sam_annotator.annotator_2d:Annotator2d')
File ~\AppData\Local\miniforge3\envs\micro-sam\Lib\site-packages\npe2_command_registry.py:34, in CommandHandler.resolve(self=CommandHandler(id='micro-sam.annotator_2d', func...icro_sam.sam_annotator.annotator_2d:Annotator2d')) 32 self.function = utils.import_python_name(self.python_name) 33 except Exception as e: ---> 34 raise RuntimeError( self.python_name = 'micro_sam.sam_annotator.annotator_2d:Annotator2d' self = CommandHandler(id='micro-sam.annotator_2d', function=None, python_name='micro_sam.sam_annotator.annotator_2d:Annotator2d') 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 'micro_sam.sam_annotator.annotator_2d:Annotator2d': DLL load failed while importing _nifty: Das angegebene Modul wurde nicht gefunden.
i have the exact same issue, but i installed from source
It seems like there is an issue with installation on windows. It was also reported here: https://forum.image.sc/t/issues-with-the-installation-of-micro-sam/101470/3
Please check my latest reply there for potential ways to mitigate the issues. We will also look into testing installation on windows ourselves to fix this.
Using a python version smaller than 3.12 fixes the issue, see discussion in the forum post for details. I will leave this open, as we either want to fix the issue for 3.12 or alternatively pin a version smaller than 3.12 to avoid the issue.
the yaml file provided by you specifies to use a phython version below 3.12python <3.12So this is what I have used, yet the problem persists???Best,MatthiasVon meinem/meiner Galaxy gesendet -------- Ursprüngliche Nachricht --------Von: Constantin Pape @.> Datum: 13.09.24 21:33 (GMT+01:00) An: computational-cell-analytics/micro-sam @.> Cc: mocherry @.>, Author @.> Betreff: [EXTERN] Re: [computational-cell-analytics/micro-sam] ImportError: DLL load failed while importing _nifty: Das angegebene Modul wurde nicht gefunden (Issue #684) Using a python version smaller than 3.12 fixes the issue, see discussion in the forum post for details. I will leave this open, as we either want to fix the issue for 3.12 or alternatively pin a version smaller than 3.12 to avoid the issue.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
Hi @mocherry and @katja-loewe,
Thanks for reporting the issue. It seems like an issue with the latest build version of nifty.
We have updated the yaml files in micro-sam (for installing micro-sam from source) and added a PR in conda-forge to update the micro-sam package. Kindly let us know if you still encounter the issue after the latest fix.
Let us know if you still encounter the issue after the fixes are merged. I will ping here once both the PRs are merged.
This is fixed now, and we are working on a better solution, see #813