简体   繁体   中英

import cv2 failed - installing OpenCV for Python 2.7 for Windows

I am trying to install OpenCV-python for Windows from this link - http://docs.opencv.org/trunk/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.html#install-opencv-python-in-windows

All steps executed properly, except the last step ,ie,

>>> import cv2

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import cv2
ImportError: DLL load failed: The specified module could not be found.

As you can see in the error message there is some problem with loading one (or more) DLL. Basing on this error message it's impossible to tell which file is missing, you need to use Dependency walker to check it (open cv2.pyd file using this tool). It will give list of files which are required to load cv2.pyd . Files with yellow ? sign are missing and MAY (but may not..) cause your problem. For me following files are missing:

API-MS-WIN-CORE-KERNEL32-PRIVATE-L1-1-1.DLL
API-MS-WIN-CORE-PRIVATEPROFILE-L1-1-1.DLL
API-MS-WIN-SERVICE-PRIVATE-L1-1-1.DLL
API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL
EXT-MS-WIN-NTUSER-UICONTEXT-EXT-L1-1-0.DLL
IESHIMS.DLL

but everything is working fine. Most likely Dependency walker will tell that some opencv files are missing (like opencv_core***.dll *** - version number). Put them in the same directory as cv2.pyd or add their location to python_path variable.
If it will not solve your problem give us more informations about what you have already tried - googling for opencv python DLL load failed gives lot of results and generally you should try them before posting qustion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM