import cntk in virtualenv failed with the error DLL not found.
Hi,
I tried import cntk but it failed with the error "DLL load failed" in Windows 10 and Python 3.6.2 64bit. cntk is CPU Only. https://docs.microsoft.com/en-us/cognitive-toolkit/setup-windows-python?tabs=cntkpy23
However, when I tried without virtualenv, it succeeded. This is the error which I met in virtualenv
(env) C:\Users\kemura\Desktop\myprogram_personal\blog\cntk_local>python
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import cntk
Traceback (most recent call last):
File "C:\Users\kemura\Desktop\myprogram_personal\blog\cntk_local\env\lib\site-packages\cntk\cntk_py.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\kemura\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 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 948, 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>
File "C:\Users\kemura\Desktop\myprogram_personal\blog\cntk_local\env\lib\site-packages\cntk\__init__.py", line 10, in <module>
from . import cntk_py
File "C:\Users\kemura\Desktop\myprogram_personal\blog\cntk_local\env\lib\site-packages\cntk\cntk_py.py", line 21, in <module>
_cntk_py = swig_import_helper()
File "C:\Users\kemura\Desktop\myprogram_personal\blog\cntk_local\env\lib\site-packages\cntk\cntk_py.py", line 20, in swig_import_helper
return importlib.import_module('_cntk_py')
File "C:\Users\kemura\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: 指定されたモジュールが見つかりません。
However, pip install succeeded before import cntk.
(env) PS C:\Users\kemura\Desktop\myprogram_personal\blog\cntk_local> pip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.3-cp36-cp36m-win_amd64.whl
Requirement already satisfied: cntk==2.3 from https://cntk.ai/PythonWheel/CPU-Only/cntk-2.3-cp36-cp36m-win_amd64.whl in c:\users\kemura\desktop\myprogram_personal\blog\cntk_local\env\lib\site-packages
Requirement already satisfied: numpy>=1.11 in c:\users\kemura\desktop\myprogram_personal\blog\cntk_local\env\lib\site-packages (from cntk==2.3)
Requirement already satisfied: scipy>=0.17 in c:\users\kemura\desktop\myprogram_personal\blog\cntk_local\env\lib\site-packages (from cntk==2.3)
What should I show in order to tell you the error ?
If you need more information, Please tell me what you need for confirming.
Seems like cntk was already installed before you triggered pip install. Could you please try to reinstall?
pip uninstall cntk
pip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.3-cp36-cp36m-win_amd64.whl
If it doesn't fix the issue, please try a fresh installation:
conda create --name cntk-py362 python=3.6.2 numpy scipy h5py jupyter
activate cntk-py362
pip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.3-cp36-cp36m-win_amd64.whl
Hi @manikjindal , this problem occurs only in virtual environment. It looks like cntk goes to check modules in Default Python lib though it is virtualenvironment, not env one when I tried import module. I will try your suggestion later.
Thanks,
Hi @kemura I have the same issue. Could you please tell me what you gave in the Path in System variable? By the way, I am not using virtualenvironment. And I am using the same CNTK-2.3 CPU only version. But it throws error "ModuleNotFoundError: No module named 'cntk._cntk_py'" when i give Import cntk in Python IDE.
VirtualEnv doesn't add environment path to PATH variable but Conda does. If your VirtualEnv environment is located at path
C:\Users<username>\.virtualenvs\env1
, then run following set PATH=C:\Users\<username>\.virtualenvs\env1;%PATH%
You can do the same in PyCharm as well by in project configuration.
Please re-open if you still encounter this issue.