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
366 views
in Technique[技术] by (71.8m points)

python - Can't import cv2; "DLL load failed"

I really didn't want to start my own question with this because it seems to be a common error here. However, having wasted hours on this now and having followed every thread I could find, none of the given answers have sorted this for me.

So my only option is to provide all the information I can about my set up and hope one of you lot can recognise the problem.

I'm running on windows 10(x64) and have installed the following prebuilt binaries from the collection here.

  1. python 3.5.0-win32 (installed from python website)
  2. numpy 1.10-cp35-win32
  3. matplotlib 1.4.3-cp35-win32
  4. opencv 3.0.0-cp35-win32

Everything was installed using "pip install file_name.whl" with no error messages. However the difference is open cv will not import and I get the following error:

>>> import cv2
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:Program Files (x86)JetBrainsPyCharm Community Edition 4.5.4helperspydevpydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ImportError: DLL load failed: The specified module could not be found.

cv2.cp35-win32.pyd plus many .dll files are installed to C:Python35Libsite-packages

I've tried renaming cv2.cp35-win32.pyd to cv2.pyd and copying the .dll files to C:Python35DLLs

I've tried using another python opencv package downloaded from the site, adding the bin directory to my PATH environment and moving the cv2.pyd file to C:Python35Libsite-packages

The same error appears every time. Any help would be appreciated!

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

In my situation, when using Pycharm to import cv2, it returned ImportError: DLL not found. However, using python intepreter to import I got *ImportError: ... not a win32 DLL ... * instead. So, in this situation, I had to download Visual C++ 2015 redistribution package and problem solved.

So to anyone who meets the same error, please make sure you have the VC++ redistribution package which was used to compile the DLL packed along the module.


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

...