Microsoft Cognitive Toolkit: ModuleNotFoundError: No module named'cntk._cntk_py'

Introduction

I've resolved the error I had when importing CNTK on a machine with a fresh installation of Windows 10, so I'll summarize it as it might be useful to someone.

The process until an error occurs

  1. I have newly installed Windows 10 Pro 1909.
  2. I have installed Python 3.6.6.
  3. I set the environment variables appropriately and also set PYTHONPATH.
  4. I have successfully installed the required Python libraries and installed CNTK 2.7.
  5. CNTK 2.7 uses CUDA 10.0, so I installed it.

Then I launched Python from the console and imported it.

python


>>> import cntk as C

Then

Traceback (most recent call last):
File "C:\Users\---\AppData\Local\Programs\Python\Python36\lib\site-packages\cntk\cntk_py.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\---\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'cntk._cntk_py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
import cntk
File "C:\Users\---\AppData\Local\Programs\Python\Python36\lib\site-packages\cntk\__init__.py", line 10, in <module>
from . import cntk_py
File "C:\Users\---\AppData\Local\Programs\Python\Python36\lib\site-packages\cntk\cntk_py.py", line 21, in <module>
_cntk_py = swig_import_helper()
File "C:\Users\---\AppData\Local\Programs\Python\Python36\lib\site-packages\cntk\cntk_py.py", line 20, in swig_import_helper
return importlib.import_module('_cntk_py')
File "C:\Users\---\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: The specified module could not be found.

I've omitted the user name, but apparently I'm getting ModuleNotFoundError and ImportError (・ _ ・;)

Solution

In conclusion, I was able to solve it by installing Microsoft Visual C ++ 2015 Redistributable.

Microsoft Visual C++ 2015 Redistributable

After downloading and installing the installer for my machine from the URL, I was able to successfully import CNTK.

Recommended Posts

Microsoft Cognitive Toolkit: ModuleNotFoundError: No module named'cntk._cntk_py'
ModuleNotFoundError: No module named'py4j'
ModuleNotFoundError: No module named'flask_sqlalchemy'
[Python] ModuleNotFoundError: No module named'urlparse'
Python error: ModuleNotFoundError: No module named'flask'
ModuleNotFoundError in poetry: No module named'setuptools'
Today's python error: ModuleNotFoundError: No module named
Today's python error: ModuleNotFoundError: No module named
ModuleNotFoundError: No module named'***' when running Flask
Today's python error: ModuleNotFoundError: No module named'requests'
ModuleNotFoundError in Python: No module named story
Today's python error: ModuleNotFoundError: No module named'bs4'
ModuleNotFoundError: No module named'_bz2' error in pyenv Python
Import cv2 ModuleNotFoundError: No module named'cv2' in python3
ModuleNotFoundError: No module What to do if you get'tensorflow.contrib'