Ask Your Question
3

Failure to import cv2 in python : DLL load failed.

asked 2015-08-27 21:46:31 -0600

ChaoyuanYeh gravatar image

Two weeks ago, I built openCV-3.0.0, using Visual Studio 2013 x64 on Windows 7, with Python 3.4.3. I've copied cv2.pyd into the Python34\Lib\site-packages folder. It was working.

Today, when I typed import cv2, I was given this error message: ImportError: DLL load failed: The specified module could not be found.

I couldn't remember everything I did to my computer in the past two weeks, but I did remember I installed openSSH for windows. When I checked my path variable, surprisingly, there is only one entry left for this software. Apparently this software erase previously existing path variable entries. While I suspect this could be the cause of the problem, I couldn't solve it. I added the path to opencv binaries, and Windows\System32, Windows\SysWow64 back but they didn't help.

When I use dependency walker, I saw the same list of missing dlls as reported [here]. (http://stackoverflow.com/questions/17...), which, according to the original poster, was misleading.

Then I'm wondering : 1) Is it indeed the path variable that gave me problem? If so, how can I restore it? 2) Could it be something other than path variable? How then can I troubleshoot?

edit retag flag offensive close merge delete

Comments

1

if you built the cv2.pyd yourself, it's probably a good idea, to make a second attempt with

cmake -DBUILD_SHARED_LIBS=OFF

this should result in a (fat ~10mb) cv2.pyd, that does no more depend on opencv dlls (if you don't count opencv_ffmpeg.dll)

berak gravatar imageberak ( 2015-08-28 01:14:31 -0600 )edit

Thanks! That's a very good suggestion !

ChaoyuanYeh gravatar imageChaoyuanYeh ( 2015-08-28 14:50:15 -0600 )edit

how does one execute that command? I tried while in the CMake\bin folder and it told me that it "does not appear to contain CMakeLists.txt". I then tried to do it in opencv-master/include where I found the file CmakeLists.txt but cmake is not a valid command there. Any help would be appreaciated

ChrisRR gravatar imageChrisRR ( 2016-11-24 10:50:48 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
3

answered 2015-08-29 22:01:38 -0600

ChaoyuanYeh gravatar image

As it turned out, it's a rather silly mistake. Because I was still thinking it could be due to bad path variable setup, I tried using PATH editor to look at it. Somehow, it marks the path to OpenCV binaries as missing folder while printing the content corretly. I clicked Edit, did nothing and clicked Save and the problem was solved. Lesson learned here: use a better tool to edit path variable.

edit flag offensive delete link more
0

answered 2018-04-05 16:37:38 -0600

mhaghighat gravatar image

The issue is due to the missing python3.dll file in Anaconda3.

To fix the issue, you should simply copy the python3.dll to C:\Program Files\Anaconda3 (or wherever your Anaconda3 is installed).

You can get the python3.dll by downloading the binaries provided at the bottom of the Python's Release page and extracting the python3.dll from the ZIP file.

edit flag offensive delete link more

Comments

sorry, but this is a bad answer, and not really related to the original problem.

also note, that opencv does not maintain any conda distribution.

berak gravatar imageberak ( 2018-04-05 21:08:13 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-08-27 21:46:31 -0600

Seen: 31,892 times

Last updated: Apr 05 '18