简体   繁体   中英

Can't import cv2 on Python 3.5 DLL load failed

I've been struggling with this problem for a day and haven't been able to find a working solution. When I import cv2 with python-v, I get

>>> import cv2 Traceback (most recent call last): 
File "<stdin>", line 1, in <module> File "<frozen importlib._bootstrap>", 
line 969, in _find_and_load File "<frozen importlib._bootstrap>", 
line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", 
line 666, in _load_unlocked File "<frozen importlib._bootstrap>", 
line 577, in module_from_spec File "<frozen importlib._bootstrap_external>", 
line 914, in create_module File "<frozen importlib._bootstrap>", 
line 222, in _call_with_frames_removed 
ImportError: DLL load failed: The specified module could not be found.

I am using Python 3.5 with Anaconda3 on windows 10 64 bit. I have gone through all the other posts on stackoverflow regarding this. Based on that here is some information of the things I have done:

  1. I installed Visual Studio 14.0 from the from the VC++ 2015 standalone tools here http://landinghub.visualstudio.com/visual-cpp-build-tools

  2. I deleted my old isual C++ redistributable packages and installed https://www.microsoft.com/en-gb/download/details.aspx?id=48145 . My msvcp140.dll is present here: C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\redist\\x64\\Microsoft.VC140.CRT

  3. I installed opencv python from this link https://pypi.python.org/pypi/opencv-python#downloads

  4. I copied the cv2.pyd package into my Lib/site-package directory

Any suggestions on what I'm missing? Thanks in advance!!

Suggest to download OpenCV 3.2.0 for Python 3.5 either Windows 32-bit or 64-bit form this Unofficial Windows Binaries for Python Extension Packages website. Look for file with suffix as opencv_python‑3.2.0+contrib‑cp35‑cp35m for your case. The +contrib is the ones with opencv_contrib modules.

Then type below command to install the binary from your location drive:

  • pip install opencv_python‑3.2.0+contrib‑cp35‑cp35m‑win32.whl (32-bit version) or
  • pip install opencv_python‑3.2.0+contrib‑cp35‑cp35m‑win_amd64.whl (64-bit version)

Before install this binary, make ensure the previous installation is completely removed or you may create a new conda env to install it. If it's successfully installed, it would be showed up in conda list . Then you can check its version by import cv2 , print cv2.__version__ .

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