Ask Your Question

building opencv-python with visual studio 2010sp 1

asked 2013-05-07 01:29:14 -0600

noSkill gravatar image

I built opencv 2.4 from sources, but after installation i can't access it from python.

Import cv2 fails with error:

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

I found that my cv2.pyd has size about 1 mb, while cv2.pyd from opencv installer has size about 9 mb.

i run cmake with this argument:


compiling with vs 2010sp1 on windows 7x64 for 32bit version of python2.7


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-05-07 03:14:20 -0600

berak gravatar image

your build probably used BUILD_SHARED_LIBS in the cmake settings, so it's not using static, but dynamic libs(dlls). in this case:

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

means, that the cv2 module was loaded, but not the other opencv-dlls, you need to adjust your PATH environment var, add the path to the opencv-dlls here, so cv2.pyd can find them at runtime.

if you don't want that, untick BUILD_SHARED_LIBS in cmake-gui, and rebuild opencv with static libs. this will give you a huge, but self-contrained cv2.pyd (like the 9mb with the prebuilt one)

edit flag offensive delete link more


Thank you. It solved my issue.

noSkill gravatar imagenoSkill ( 2013-05-07 12:21:38 -0600 )edit

@berak : I unticked BUILD_SHARED_LIBS, built it, got a >8MB cv2.pyd, copied it to Python27\Lib\site-packages. Still import cv2 gives the same error. Later I added build folder of cv2.pyd (which contains all other libs) to sys.path. Now it works fine. Why is it? No way to create cv2.pyd which doesn't depent upon the other libs?

Abid Rahman K gravatar imageAbid Rahman K ( 2013-09-03 08:03:07 -0600 )edit

since you seem to be on win, try to drop it on dependancy walker, you'll see, what dlls it pulls in ( or not )

berak gravatar imageberak ( 2013-09-03 08:13:07 -0600 )edit

I dont have used "walker" before. But when I try to open python27/Lib/site-packages/cv2.pyd with walker, it shows error opening two dll files, "GPSVC.DLL" and "IESHIMS.DLL". Error msg : Error opening the file. The system couldnot find the specified file. Is it that? Or what should I do?

Abid Rahman K gravatar imageAbid Rahman K ( 2013-09-03 08:31:02 -0600 )edit

no, that's not the problem. if you see any opencv-related dlls there, then you know, that cv2.pyd will load them on startup.

hey i did a static build as well right now, and it has no dependancies, and it works without having opencv on the path for me. strange.

on the other hand, i ran the INSTALL proj to copy it over.

berak gravatar imageberak ( 2013-09-03 08:47:41 -0600 )edit

can you send me your cmake log and cmakecache.txt to [email protected]?

Abid Rahman K gravatar imageAbid Rahman K ( 2013-09-03 08:51:26 -0600 )edit

What is the use of "BUILD_PACKAGE"? Should it be ticked or unticked? Also BUILD_WITH_DEBUG_INFO and BUILD_WITH_STATIC_CRT?

Abid Rahman K gravatar imageAbid Rahman K ( 2013-09-03 08:54:54 -0600 )edit

sure, second (expect px1704)

berak gravatar imageberak ( 2013-09-03 09:03:29 -0600 )edit

no idea, really. i had all 3 ON

berak gravatar imageberak ( 2013-09-03 09:05:31 -0600 )edit

Problem solved for branch 2.4. I think issue was I didn't check static_crt one. may be.. no idea... Anyway thank you for your share. Now I think what is the problem with master branch and python :)

Abid Rahman K gravatar imageAbid Rahman K ( 2013-09-03 09:22:57 -0600 )edit

Question Tools


Asked: 2013-05-07 01:29:14 -0600

Seen: 1,239 times

Last updated: May 07 '13