ITK: DLL Load failed while import _ITKCommonPython error

Description

Getting error while reading mesh using ITK.

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 a = itk.meshread("C:\\Users\\pranj\\Downloads\\testpoly.vtk", itk.D)
      2 print(a)

File ~\anaconda3\envs\mypython3\lib\site-packages\itk\support\extras.py:1080, in meshread(filename, pixel_type, fallback_only)
   1078     except (KeyError, itk.TemplateTypeError):
   1079         pass
-> 1080 TemplateReaderType = itk.MeshFileReader
   1081 io_filename = f"{filename}"
   1082 increase_dimension = False

File ~\anaconda3\envs\mypython3\lib\site-packages\itk\support\lazy.py:137, in LazyITKModule.__getattribute__(self, attr)
    135 module = self.__belong_lazy_attributes[attr]
    136 namespace = {}
--> 137 base.itk_load_swig_module(module, namespace)
    138 self.loaded_lazy_modules.add(module)
    139 for k, v in namespace.items():

File ~\anaconda3\envs\mypython3\lib\site-packages\itk\support\base.py:102, in itk_load_swig_module(name, namespace)
    100     deps = l_data.get_module_dependencies()
    101     for dep in deps:
--> 102         itk_load_swig_module(dep, namespace)
    104 if itkConfig.ImportCallback:
    105     itkConfig.ImportCallback(name, 0)

File ~\anaconda3\envs\mypython3\lib\site-packages\itk\support\base.py:102, in itk_load_swig_module(name, namespace)
    100     deps = l_data.get_module_dependencies()
    101     for dep in deps:
--> 102         itk_load_swig_module(dep, namespace)
    104 if itkConfig.ImportCallback:
    105     itkConfig.ImportCallback(name, 0)

    [... skipping similar frames: itk_load_swig_module at line 102 (2 times)]

File ~\anaconda3\envs\mypython3\lib\site-packages\itk\support\base.py:102, in itk_load_swig_module(name, namespace)
    100     deps = l_data.get_module_dependencies()
    101     for dep in deps:
--> 102         itk_load_swig_module(dep, namespace)
    104 if itkConfig.ImportCallback:
    105     itkConfig.ImportCallback(name, 0)

File ~\anaconda3\envs\mypython3\lib\site-packages\itk\support\base.py:110, in itk_load_swig_module(name, namespace)
    107 # SWIG-generated modules have 'Python' appended. Only load the SWIG module
    108 # if we haven't already.
    109 loader = LibraryLoader()
--> 110 l_module = loader.load(swig_module_name)
    112 # OK, now the modules on which this one depends are loaded and
    113 # template_feature-instantiated, and the SWIG module for this one is also loaded.
    114 # We're going to put the things we load and create in two places: the
   (...)
    120 # stomp on an existing 'swig' namespace, nor do we want to share 'swig'
    121 # namespaces between this_module and namespace.
    123 if namespace is None:

File ~\anaconda3\envs\mypython3\lib\site-packages\itk\support\base.py:259, in LibraryLoader.load(self, name)
    257     # since version 3.4: Use importlib.util.find_spec() instead.
    258     l_spec = importlib.util.find_spec(name)
--> 259     l_spec.loader.exec_module(l_module)  # pytype: disable=attribute-error
    260     return l_module
    261 finally:

File <frozen importlib._bootstrap_external>:843, in exec_module(self, module)

File <frozen importlib._bootstrap>:219, in _call_with_frames_removed(f, *args, **kwds)

File ~\anaconda3\envs\mypython3\lib\site-packages\itk\support\..\ITKCommonPython.py:13, in <module>
     11 # Import the low-level C/C++ module
     12 if __package__ or "." in __name__:
---> 13     from . import _ITKCommonPython
     14 else:
     15     import _ITKCommonPython

ImportError: DLL load failed while importing _ITKCommonPython: The specified module could not be found.

This could potentially create problems when working with Coiled clusters.

Steps to Reproduce

Expected behavior

Actual behavior

Reproducibility

100%

Versions

5.3rc4, 5.3rc3, 5.3rc2.

Environment

In a Windows 10 Home VM where the host machine is Ubuntu 20. When ITK is installed in a conda environment.

Additional Information

5.3rc1 and 5.2.1post1 work fine.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (17 by maintainers)

Most upvoted comments

Status update: itk-5.3rc4.post2 incorporates #3494, and dask support is stable! 🎉 (caveat: add import itk in delayed dask functions).

The Anaconda Windows issue is separate, we could address with conda-forge native package, perhaps via clang module optimized packages (I am investigating this).