ImportError from cv2.pyd when building with opencv_contrib modules [closed]

asked 2016-10-24 15:55:54 -0500

eggplant gravatar image

updated 2016-10-24 17:52:46 -0500

Hi, I followed this tutorial:

I used files from the OpenCV git repos, making sure all were at the same version, 3.1.0.

Only difference is that I added the 'opencv_contrib/modules' path for OPENCV_EXTRA_MODULES_PATH.

I'm on Windows 10 x64 but am running 32bit Python. Made sure all my python2 paths were correct. I ran the CMake GUI using 'Visual Studio 14.0 2015', not selecting the 64 version.

It configures and generates fine. I open the OpenCV.sln and build the solution and install using Release and Win32 settings.

It successfully creates a new cv2.pyd in the site-packages directory, however, I get this error trying to import cv2:

ImportError: DLL load failed: The specified module could not be found.

I replaced the cv2.pyd file with the one that comes with the OpenCV 3.1.0 Win install and that works fine, however, I need to use these extra modules, specifically xfeatures2d. I do notice that the .pyd that works is 36,827 KB while the one that is created during the build is only 2,961 KB. Maybe I'm missing something?

Please advise! Thanks ahead.


  • Python 2.7.6 32-bit
  • CMake 3.7.0
  • Numpy 1.8.1
  • Visual Studio 14.0 2015
  • Windows 10 Pro 64-bit


EDIT: after looking on slackoverflow, I found the answer! I had to copy the .dll files into my site-packages, something that wasn't in the instructions.


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by eggplant
close date 2016-10-24 17:51:13.385315



building with static libs (cmake -DBUILD_SHARED_LIBS=OFF) would have been a much better idea (no more dll dependancies)

berak gravatar imageberak ( 2016-10-25 00:02:06 -0500 )edit

nice! I didn't see that option being specifically mentioned so I didn't think it was an important setting since there were so many pre-filled by CMake. Thanks for the tip :)

eggplant gravatar imageeggplant ( 2016-10-25 12:52:52 -0500 )edit