opencv-python 3.0 with python 3.5 on windows [closed]
A long time ago I managed to get opencv-python 3 working with python 3.4 on windows (which was a struggle). I wrote a lot of good code, then lost my working file system. I simply cannot reproduce a working system with a new install of python 3.5 on windows. The sad moment is when I try to import cv2: ImportError: DLL load failed: The specified module could not be found.
Any help would really be hugely appreciated as I've been at this for way too long. Here are answers to the usual questions:
- Microsoft Windows [Version 10.0.10240]
- Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:16:59) [MSC v.1900 32 bit (Intel)] on win32
- pip shows that opencv-python (3.0.0) is installed
- I installed it from the wheel on Gohlke's site: opencv_python‑3.0.0‑cp35‑none‑win32.whl
- I have these entries in my PATH : C:\Python35\Scripts\; C:\Python35\; %OPENCV_DIR%\bin;
- I have the environment variable: OPENCV_DIR = C:\opencv\build\x64\vc12\
(and I've tried the variants with x86 and vc11) - from python, it can find the module:
>>> import imp >>> imp.find_module('cv2') (<_io.BufferedReader name='C:\\Python35\\lib\\site-packages\\cv2.cp35-win32.pyd'>, 'C:\\Python35\\lib\\site-packages\\cv2.cp35-win32.pyd', ('.cp35-win32.pyd', 'rb', 3))
I tried all the steps again on a second machine (all the same as above except Windows 8.1). Every other package I install works fine (numpy, matplotlib, flask, more). Same problem. How do I debug this? (Thank you for looking at this problem).
Next day:
Phew! I got things working again. I'm adding these details in the hope that it will help someone else.
First, in answer to berak's question: Dependency Walker was giving me red -- cannot find file specified -- for the following modules (in this case, on my Win 8.1 laptop):
API-MS-WIN-CORE-KERNEL32-PRIVATE-L1-1-1.DLL
API-MS-WIN-CORE-PRIVATEPROFILE-L1-1-1.DLL
API-MS-WIN-SERVICE-PRIVATE-L1-1-1.DLL
API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL
EXT-MS-WIN-NTUSER-UICONTEXT-EXT-L1-1-0.DLL
IESHIMS.DLL
Chasing those down turned out to be a red herring. I spoke to a friend at work who warned me not to trust Dependency Walker's errors (as is does not always correctly mimic how newer Windows OS find a DLL). It seems other folks have also been led down the wrong path (try searching the web for "Dependency Walker is misleading").
Here's what worked for me (and if anyone is expert in DLL registration conflicts, please correct me):
I was previously using the opencv wheel (from the Gohlke site) that was built for Windows Python 3.4. The dependency was on Visual C++ 2010. These wheels don't include the VC++ Redistributable for the compiler that was used (I assume because of Microsoft licensing restriction). So, I had to separately download & install Microsoft Visual C++ 2010 Redistributable.
For the newer wheel, that was built for Windows Python 3.5, Gohlke site says the dependency is on Visual C++ 2015. So I had to download & install Microsoft Visual C++ 2015 Redistributable. Which ...
"I installed it from the wheel on Gohlke's site: opencv_python‑3.0.0‑cp35‑none‑win32.whl" -hmm, 3rd party install, not recommended.
what is the size of cv2.pyd ? sounds like a problem with dynamic linking
try to throw cv2.pyd at dependancy walker
how did you install opencv ?
In site-packages, I've got cv2.cp35-win32.pyd (1,448 KB)
This smells fishy... no cv2.pyd. Dependency Walker is showing a lot of red on that file.
The Gohlke site (http://www.lfd.uci.edu/~gohlke/python...) seems to be the de facto location where python developers pick up windows binaries to avoid having to build them on their own. If I don't pull from there, is there another source for already-built?
unfortunately, this seems to give you a dependancy problem. try the depwalker !
the recommended way is still, to build statically from src, which would result in a huge(>10mb) cv2.pyd, which does no more rely on opencv dlls.
my current guess is, that your cv2.pyd depends on opencv_core, opencv_videoio, etc, while you only got opencv_world in your %OPENCV_DIR%/bin folder ?
a lot of red things like what ? the opencv related ones are the interesting ones.
so, where are we now ? it seems, you made some progress ;)
I did make progress, thank you. This forum wouldn't let me add an answer, because I'm too new, so I just appended the details to the original question. Bottom line: got it working by guessing that there were DLL registrations that failed, and re-registering.
I have the same problem with "ImportError: DLL load failed: The specified module could not be found" with OpenCV 3.1 and Python 3.5 ... but installed Microsoft Visual C++ 2015 Redistributable still didn't solve my problem. Why? Any suggestions?
After many attempts using other OpenCV packages and then the Gohlke site - I went into my python 3.+ folder and deleted everything (including in subfolders) that said cv2... and opencv... and the reinstalled the Gohlke .whl - everything works now!(of course don't forget to have your Visual C++ Runtime Redistributables from Microsoft installed) - Almost forgot - I removed the 'set' OpenCV windows path variable from the command prompt as well. You'll get it working - try everything!