2
votes

I wrote a gui program "test.py" with module opencv, Tkinter, PIL Numpy and some buildin modules. I used py2exe to generate a exe file for this program and the exe file ran well on my PC, but when i tried on other PC, it gave me

File "test.py", line 8 in File "cv2.pyc", line 12 in File "cv2.pyc", line 10, in __load ImportError: DLL load failed the specified module could not be found

My PC has Python is 32 bit

1
Your are probably using some absolute path in your code which doesn't exists at the other pcuser 12321
Was your computer windows 10 and the other computer a different version of windows?bw4sz

1 Answers

0
votes
  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%\Lib\site-packages\PyQt4' folder or PATH. I encountered this problem myself when building my own version of OpenCV from git repo.