pythonmxnet

Cannot import mxnet package in my environment


I want to install mxnet with gpu. and used pip install mxnet-cu90. However, when I am importing the package I come across this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\__init__.py", line 24, in <module>
    from .context import Context, current_context, cpu, gpu, cpu_pinned
  File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\context.py", line 24, in <module>
    from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
  File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\base.py", line 213, in <module>
    _LIB = _load_lib()
  File "C:\Users\Anuj\anaconda3\envs\py36\lib\site-packages\mxnet\base.py", line 204, in _load_lib
    lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
  File "C:\Users\Anuj\anaconda3\envs\py36\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found 

I tried reinstalling by downloading .whl file from this but it didn't work. Its still giving the same error.

I am using python 3.6.12.


Solution

  • I still don't know what was causing this problem but I solved by installing the package from conda.

    First I created a brand new environment and used

    conda install -c anaconda mxnet-mkl

    Hopefully it works for you too.