I have tried both the script setup and pip install methods a couple of times now, but still not able to run the demos.
In the demo Examples/Image/Detection I am not able to run the command python DetectionDemo.py. This is the output:
training FasterRCNN
Traceback (most recent call last):
File ".\DetectionDemo.py", line 59, in
eval_model = od.train_object_detector(cfg)
File "C:\cntk-2-2\CNTK-Samples-2-2\Examples\Image\Detection\utils\od_utils.py", line 19, in train_object_detector
from FasterRCNN.FasterRCNN_train import prepare, train_faster_rcnn
File "C:\cntk-2-2\CNTK-Samples-2-2\Examples\Image\Detection\FasterRCNN\FasterRCNN_train.py", line 30, in
from utils.od_mb_source import ObjectDetectionMinibatchSource
File "C:\cntk-2-2\CNTK-Samples-2-2\Examples\Image\Detection\utils\od_mb_source.py", line 9, in
from utils.od_reader import ObjectDetectionReader
File "C:\cntk-2-2\CNTK-Samples-2-2\Examples\Image\Detection\utils\od_reader.py", line 8, in
import cv2 # pip install opencv-python
File "C:\Users\krberge\AppData\Local\Continuum\Anaconda3\lib\site-packages\cv2__init__.py", line 9, in
from .cv2 import *
ImportError: DLL load failed: The specified module could not be found.
PS C:\cntk-2-2\CNTK-Samples-2-2\Examples\Image\Detection>
From what I understand, this boils down to the cv2 import, because the command python -c "import cv2" outputs a similar error message
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\krberge\AppData\Local\Continuum\Anaconda3\lib\site-packages\cv2__init__.py", line 9, in
from .cv2 import *
ImportError: DLL load failed: The specified module could not be found.
Runnin pip install opencv-python outputs that everything is up to date.
Not really sure what is missing here and how python/anaconda does imports.
I also noticed that the example I'm trying to run is using Fast R-CNN, so I followed the steps in the readme there too, but pip install dlib failes here. It says cmake is missing. After installing cmake with conda install cmake I get a new error saying that the cmake configuration failed.
I think the tutorial/install guide might be inadequate here, because I'm not able get anything to work by following the guide.
How about trying the following sites regarding import cv2?
https://stackoverflow.com/questions/33200025/cant-import-cv2-dll-load-failed
or
https://github.com/skvark/opencv-python/issues/36
The situation is similar to yours.
There are a lot of suggestions on how to solve this, but this was actually very easy to solve when using Anaconda. The problem is not the Visual C++ 2015 redistribution, but rather the python3.dll which is missing from
C:\Users\username\AppData\Local\Continuum\Anaconda3 as your second link suggests.
A lot of these sites and answers on stack overflow suggests downloading it manually, but according to this thread https://github.com/ContinuumIO/anaconda-issues/issues/1394 the most recent anaconda packages should all include the missing python3.dll file. So by updating python with conda, this was solved:
conda update python
Should the installation guide be changed to a more recent version of the anaconda3 package that includes the missing dll? https://docs.microsoft.com/en-us/cognitive-toolkit/setup-windows-python?tabs=cntkpy22
If you want to install of dlib, the following command may be useful:
conda install -c menpo dlib=18.18
I found a description regarding this command, but it's written in Japanese(my native language), and I've not found similar description in English as far as I checked..
It looks like installing CNTK breaks Anaconda in some way. Here is steps to reproduce it:
I have exactly the same issue. CNTK breaks the latest Anaconda 5.0.0 on windows 10 x64.
First I noticed the ImportError in matplotlib.pyplot after update of existing conda installation to the latest version. The clean reinstall didn't helped. Import error re-appears immediately after CNTK install.
For me it is a show stopper, please suggest a workaround.
Here are my findings:
CNTK installs an additional copy of zlib.dll into
The original copy is located in
The CNTK's version is outdated
The conda start script places
So wrong version of the library is loaded
I've tried to replace zlib in root by newer version. This way matplotlib is partially functional, although I've found issues with pyplot.imsave
I have the same issue on Windows 7: CNTK breaks the Anaconda 5.0.0 release on Windows 7 x64 SP1 with the same error when importing matplotlib. Had anyone figured out the solution yet?
The workaround, that works for me as far as I was able to test is to move zlib.dll from Library\Bin to anaconda root, overriding the one that installed by CNTK. The CNTK looks pretty fine with the newer version of zlib.
Thanks, but as you said, there are still some problems with matplotlib modules, so it looks like a partial solution.
That was actually an issue in anaconda packages, right now it works fine.
Just ran into the same problem today (10/26/2017) with CNTK 2.2, Anaconda3 5.0.1 (64-bit), and having problems withn matplotlib. Still not fixed.
Update: just uninstalled latest Anaconda3 (windows, 64-bit) and installed it again (without CNTK this time). Confirmed that the matplotlib problem exists just in the Anaconda install. Uninstalled & installed Anaconda 4.4.0 (windows, 64-bit). Matplotlib works fine now. Installed CNTK 2.2 on top of this, matplotlib still works fine.
It should be.
The problem with matplotlib was caused by a separate issue (https://github.com/ContinuumIO/anaconda-issues/issues/6535), it's not actually related to CNTK.
I also had the .cv2 error. The https://github.com/Azure/ObjectDetectionUsingCntk repo on github has an opencv whl at the following location. Pip installing that solved my cv2 problem.
ObjectDetectionUsingCntk\resources\python35_64bit_requirements\opencv_python-3.2.0-cp35-cp35m-win_amd64.whl"
HI.
I am having trouble importing cv2. I get this error:( And I tried tutorials how to get rid of this but it wont just go away:( . Any help? or suggestion? Thankyou:)
import cv2
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Lenovo\Anaconda3\envs\opencv-env\lib\site-packagescv2__init__.py", line 4, in
from .cv2 import *
ImportError: Module use of python27.dll conflicts with this version of Python.
Most helpful comment
There are a lot of suggestions on how to solve this, but this was actually very easy to solve when using Anaconda. The problem is not the
Visual C++ 2015 redistribution, but rather thepython3.dllwhich is missing fromC:\Users\username\AppData\Local\Continuum\Anaconda3as your second link suggests.A lot of these sites and answers on stack overflow suggests downloading it manually, but according to this thread https://github.com/ContinuumIO/anaconda-issues/issues/1394 the most recent anaconda packages should all include the missing
python3.dllfile. So by updating python with conda, this was solved:Should the installation guide be changed to a more recent version of the anaconda3 package that includes the missing dll? https://docs.microsoft.com/en-us/cognitive-toolkit/setup-windows-python?tabs=cntkpy22