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

I’ve installed mxnet-cu101 with the conda installation instructions.

however when i try to import mxnet I get the infamous [WinError 126]

I ran a diagnosis script from a github issue with similar question:

AMD FX(tm)-4100 Quad-Core Processor

----------Python Info----------
Version      : 3.7.6
Compiler     : MSC v.1916 64 bit (AMD64)
Build        : ('default', 'Jan  8 2020 20:23:39')
Arch         : ('64bit', 'WindowsPE')
------------Pip Info-----------
Version      : 19.3.1
Directory    : C:\Users\tt\Anaconda3\envs\d2l\lib\site-packages\pip
----------MXNet Info-----------
Traceback (most recent call last):
  File "diagnose.py", line 95, in check_mxnet
    import mxnet
  File "C:\Users\tt\Anaconda3\envs\d2l\lib\site-packages\mxnet\__init__.py", line 24, in <module>
    from .context import Context, current_context, cpu, gpu, cpu_pinned
  File "C:\Users\tt\Anaconda3\envs\d2l\lib\site-packages\mxnet\context.py", line 24, in <module>
    from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
  File "C:\Users\tt\Anaconda3\envs\d2l\lib\site-packages\mxnet\base.py", line 213, in <module>
    _LIB = _load_lib()
  File "C:\Users\tt\Anaconda3\envs\d2l\lib\site-packages\mxnet\base.py", line 204, in _load_lib
    lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
  File "C:\Users\tt\Anaconda3\envs\d2l\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

----------System Info----------
Platform     : Windows-7-6.1.7601-SP1
system       : Windows
node         : tt-PC
release      : 7
version      : 6.1.7601
----------Hardware Info----------
machine      : AMD64
processor    : AMD64 Family 21 Model 1 Stepping 2, AuthenticAMD
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0240 sec, LOAD: 0.7120 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0000 sec, LOAD: 0.2430 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0010 sec, LOAD: 0.1430 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0350 sec, LOAD: 0.1930 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0000 sec, LOAD: 0.5400 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0210 sec, LOAD: 0.1620 sec.
----------Environment----------

Please help, I’m unable to run any of the jupyter notebook code because of this issue.

Hi,
I believe it’s an issue with the system’s environment variable setting.
From your diagnosis output, I found that although you installed conda, you’re not using conda’s version of python. During the installation of conda there’s an option of adding conda to PATH environment variable, please tick that one during your installation (though not recommended by conda, it would make life easier by setting conda’s python as the default one). After re-installation, please re-confirm that your python is the Anaconda’s version, and run python -m pip install mxnet-cu101==1.6.0b20190926 in Powershell, then try to import mxnet in your python terminal. I tried this on a fresh windows laptop and it works for me.
Please lemme know if you have any further questions regarding installation on Windows machines, and I’ll be happy to help you with that.
Hao

1 Like

I’ve followed your instructions and successfully installed mxnet using pip but still running into the same error. this is my diagnostics now:

(base) PS C:\Users\tt\ai\d2l-en> python .\diagnose.py
----------Python Info----------
Version      : 3.7.4
Compiler     : MSC v.1915 64 bit (AMD64)
Build        : ('default', 'Aug  9 2019 18:34:13')
Arch         : ('64bit', 'WindowsPE')
------------Pip Info-----------
Version      : 19.2.3
Directory    : C:\ProgramData\Anaconda3\lib\site-packages\pip
----------MXNet Info-----------
Traceback (most recent call last):
  File ".\diagnose.py", line 95, in check_mxnet
    import mxnet
  File "C:\Users\tt\AppData\Roaming\Python\Python37\site-packages\mxnet\__init__
.py", line 24, in <module>
    from .context import Context, current_context, cpu, gpu, cpu_pinned
  File "C:\Users\tt\AppData\Roaming\Python\Python37\site-packages\mxnet\context.
py", line 24, in <module>
    from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
  File "C:\Users\tt\AppData\Roaming\Python\Python37\site-packages\mxnet\base.py"
, line 213, in <module>
    _LIB = _load_lib()
  File "C:\Users\tt\AppData\Roaming\Python\Python37\site-packages\mxnet\base.py"
, line 204, in _load_lib
    lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
  File "C:\ProgramData\Anaconda3\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

----------System Info----------
Platform     : Windows-7-6.1.7601-SP1
system       : Windows
node         : tt-PC
release      : 7
version      : 6.1.7601
----------Hardware Info----------
machine      : AMD64
processor    : AMD64 Family 21 Model 1 Stepping 2, AuthenticAMD
Name
AMD FX(tm)-4100 Quad-Core Processor

----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0250 sec, LO
AD: 0.6750 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0890 sec, LOAD: 0.3
170 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.1890 sec, LOAD: 0.240
0 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.
com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0250 sec, LOA
D: 0.1700 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0310 sec, LOAD: 0.6310
 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0280 sec, LOAD: 0
.1290 sec.
----------Environment----------
(base) PS C:\Users\tt\ai\d2l-en>