OSError: [WinError 126] module could not be found

17,314

Ok finally solved!

I got to know that such error could be thrown when the file dependencies are not satisfied or not found. So to check the dependencies you go first to Visual Studio Prompt and then navigate to the folder where libmxnet.dll exists and run the following command

dumpbin /dependents libmxnet.dll

and it will show you a list of required files.

What was missing in my case are some of nVidia GPU Computing Toolkit files Cuda 9.0 as libmxnet.dll asks for them and I was having toolkit version 10.0 instead!

Share:
17,314

Related videos on Youtube

wisdom
Author by

wisdom

IT Student

Updated on June 04, 2022

Comments

  • wisdom
    wisdom almost 2 years

    I am trying to run MXNet port of SSD in python but I am facing a strange error when I run the demo saying

    OSError: [WinError 126] The specified module could not be found
    

    specifically when trying to open libmxnet.dll so I found when I tried to debug it.

    the whole error message is like this:

    >>>> kernel32
    >>>>  C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\site-packages\mxnet\libmxnet.dll
    Traceback (most recent call last):
      File "demo.py", line 2, in <module>
        import tools.find_mxnet
      File "C:\Users\wisdom\Desktop\mxnet-ssd-master\tools\find_mxnet.py", line 6, in <module>
        import mxnet as mx
      File "C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\site-packages\mxnet\__init__.py", line 24, in <module>
        from .context import Context, current_context, cpu, gpu, cpu_pinned
      File "C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\site-packages\mxnet\context.py", line 24, in <module>
        from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
      File "C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\site-packages\mxnet\base.py", line 213, in <module>
        _LIB = _load_lib()
      File "C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\site-packages\mxnet\base.py", line 204, in _load_lib
        lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
      File "C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\ctypes\__init__.py", line 353, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: [WinError 126] The specified module could not be found
    

    where first two lines with >>>> sign indicate to the lines I was trying to debug and check where/when the error is fired in ...\ctypes\__init__.py file which look like this

    if handle is None:
        x = (self._name)
        print('>>>>',x)
        self._handle = _dlopen(self._name, mode)
    

    I checked of course the existence of the requested file libmxnet.dll and it is there, but whenever it is called it throws this error!

    • Esdras Xavier
      Esdras Xavier about 5 years
      Take a look at this post, maybe can help you. And look at the documentation
    • wisdom
      wisdom about 5 years
      oh I forgot to mention that I tried to replace the code with 'WinDLL(slef._name, use_last_error=True)' but then it falls in recursion throwing 'RecursionError: maximum recursion depth exceeded while calling a Python object'!
    • Esdras Xavier
      Esdras Xavier about 5 years
      That's weird... May you post your complete code? Or just where you define self._name and what is your handle? Thanks
    • wisdom
      wisdom about 5 years
      the code can be found here and the error usually is being thrown at line 351. if I try to change _dlopen() function to WinDLL() - which I dont think I should- it will fall in recursion! I tried as well just to open python interpreter and run WinDLL('...\\libmxnet.dll') function but still the same error 'module could not be found'
    • Esdras Xavier
      Esdras Xavier about 5 years
      Well... This is the module source code right? Can you show how are you trying to use? Maybe has sometingh about the self._name which is wrong. Did you just put libmxnet.dll or the entire path to the dll file? Because I think you should do something like this "C:\\Windows\\System32\\kernel32.dll"
    • wisdom
      wisdom about 5 years
      yeah of course I put the full path but still no help! what I am trying to do is just running the code as described in the repository and the demo code could be found there as well.
    • Esdras Xavier
      Esdras Xavier about 5 years
      Ok my bad about that... I think you shold open an issue there in there into the repo. Because for me don't make any sense this error. Sorry for that. :(
    • wisdom
      wisdom about 5 years
      don't worry...I opened one already ;)
    • Ulrich Eckhardt
      Ulrich Eckhardt about 5 years
      You're actually expected to first extract a minimal reproducible example from your code and post that as part of your question inline. No volatile external links to your whole project.
  • myradio
    myradio over 3 years
    What and where the visual studio prompt is?
  • Redoman
    Redoman almost 2 years
    @myradio he just meant the windows command prompt...