Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: DLL load failed for ITK wrap python #1565

Closed
qiang-zhang-neu opened this issue Jan 14, 2020 · 4 comments
Closed

ImportError: DLL load failed for ITK wrap python #1565

qiang-zhang-neu opened this issue Jan 14, 2020 · 4 comments

Comments

@qiang-zhang-neu
Copy link

@qiang-zhang-neu qiang-zhang-neu commented Jan 14, 2020

I want to compile ITK from source and wrap with python.

My environment is:

win 10 64 bit
vs 2015
Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

What I have done:
successully compile ITK
copy all file in install/lib/site-packages to Anaconda3/envs/ITK_cpu/Lib/site-packages
add install/bin to the system environment

Then, the import ITK is OK, but error happen for img = itk.Image[itk.float, 3], and the error is:

>>> import itk
>>> a = itk.Image[itk.float, 3]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\ProgramData\Anaconda3\envs\ITK_cpu\lib\site-packages\itkLazy.py", line 52, in __getattribute__
    itkBase.LoadModule(module, namespace)
  File "D:\ProgramData\Anaconda3\envs\ITK_cpu\lib\site-packages\itkBase.py", line 128, in LoadModule
    module = loader.load(swigModuleName)
  File "D:\ProgramData\Anaconda3\envs\ITK_cpu\lib\site-packages\itkBase.py", line 253, in load
    return importlib.import_module(name)
  File "D:\ProgramData\Anaconda3\envs\ITK_cpu\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\ProgramData\Anaconda3\envs\ITK_cpu\lib\site-packages\itk\Configuration\..\ITKCommonPython.py", line 32, in <module>
    _ITKCommonPython = swig_import_helper()
  File "D:\ProgramData\Anaconda3\envs\ITK_cpu\lib\site-packages\itk\Configuration\..\ITKCommonPython.py", line 28, in swig_import_helper
    _mod = imp.load_module('_ITKCommonPython', fp, pathname, description)
  File "D:\ProgramData\Anaconda3\envs\ITK_cpu\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "D:\ProgramData\Anaconda3\envs\ITK_cpu\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 583, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1043, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: cannot find the module
@thewtex

This comment has been minimized.

Copy link
Member

@thewtex thewtex commented Jan 15, 2020

@hjmjohnson this has also been occuring in CI since 58d0016 was merged.

@qiang-zhang-neu could you please share the value of the Python3* and PYTHON* variables in your ITK build's CMakeCache.txt file?

@qiang-zhang-neu

This comment has been minimized.

Copy link
Author

@qiang-zhang-neu qiang-zhang-neu commented Jan 16, 2020

@thewtex I am not sure what's the meaning of Python3* and PYTHON*, because there are so many python related variables. Do you mean this:

//Path to a library.
PYTHON_LIBRARY:FILEPATH=D:/ProgramData/Anaconda3/envs/ITK_cpu/libs/python37.lib
//Details about finding PythonInterp
FIND_PACKAGE_MESSAGE_DETAILS_PythonInterp:INTERNAL=[D:/ProgramData/Anaconda3/envs/ITK_cpu/python.exe][v3.7.6()]
//Details about finding PythonLibs
FIND_PACKAGE_MESSAGE_DETAILS_PythonLibs:INTERNAL=[D:/ProgramData/Anaconda3/envs/ITK_cpu/libs/python37.lib][D:/ProgramData/Anaconda3/envs/ITK_cpu/include][v3.7.6()]

Or something else?

@thewtex

This comment has been minimized.

Copy link
Member

@thewtex thewtex commented Jan 16, 2020

@qiang-zhang-neu thanks, that is helpful. Is there anything like Python3_LIBRARY? Or could you share the entire file?

I suspect the Python3 CMake module is picking up the wrong library somewhere...

@qiang-zhang-neu

This comment has been minimized.

Copy link
Author

@qiang-zhang-neu qiang-zhang-neu commented Jan 16, 2020

@qiang-zhang-neu thanks, that is helpful. Is there anything like Python3_LIBRARY? Or could you share the entire file?

I suspect the Python3 CMake module is picking up the wrong library somewhere...

I am sorry. But the code is OK for ITK wrap python. No something else has been done and I don't know why it's OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.