Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

pythonxy - ImportError: DLL load failed: The specified procedure could not be found. Python

Recently, I have installed a current version of Python(x,y) package (2.7.6.0) and now when I run my python code, it shows an error:

Traceback (most recent call last):
File "D:ProjectscomparisonLagebestimmungmain.py", line 11,   in <module>
import cv2
ImportError: DLL load failed: The specified procedure could not be found.

I correctly selected opencv module during the installation.

Also, I use to have an older version of Python(x,y) before in my computer which I uninstalled before installing the new version. In that version, there was no such problem.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. Use Dependency Walker (http://www.dependencywalker.com/) on your cv2.pyd from 'site-packages'.
  2. Look at the higher-left corner, where the library tree is.
  3. Normal libraries have blue or gray icons, find libraries with red icons on the left, like this: http://i.stack.imgur.com/YiEuD.png.
  4. Find API's having a red flag and remember parent library names of the libraries with red icon. Red flag means that parent library requires some API, which is absent in the underlying library. In my case a library with the red icon is 'kernel32.dll', and it's parent libraries are msvcr90.dll, tbb.dll and the library from 'winsxs', which name's is obscured.
  5. Usually a problem can be solved by obtaining correct versions of the parent libraries. For example, you are trying to use a DLL, which is compiled for Windows Vista, on Windows XP. This DLL imports a 'InitializeCriticalSectionEx' API, which is absent in Windows XP's 'kernel32.dll'. Obtaining the XP version of your DLL or recompiling it with 'InitializeCriticalSection' instead of 'Ex' will solve the problem. Another example: you are using OpenCV compiled for use with Qt 4.8.4 and PyQt4, which contains Qt version 4.7. cv2.pyd (which is a DLL, by the way) will refuse to import because certain Qt API's required in your OpenCV are not available in 4.7's DLL's. The solution is to put Qt libraries version 4.8.4 into your '%PYTHONHOME%Libsite-packagesPyQt4' folder or PATH. I encountered this problem myself when building my own version of OpenCV from git repo.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...