首页 > 解决方案 > 为 Python 2.7 安装 opencv 时出现 DLL Load failed 错误

问题描述

我正在使用 Windows Server 2012 R2 和 Python 2.7,确切地说:

Python 2.7.15(v2.7.15:ca079a3ea3,2018 年 4 月 30 日,16:22:17)[MSC v.1500 32 位(英特尔)] 在 win32 上

最新版本的 OpenCV 库 3.4.2 无法正常工作,并产生以下错误:

>>> import cv2

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import cv2
  File "C:\Python27\lib\site-packages\cv2\__init__.py", line 3, in <module>
    from .cv2 import *
ImportError: DLL load failed: The specified module could not be found.

所以我下载了旧版本的 OpenCV 3.4.1,将 cv2.pyd 复制到 C:/Python27/lib/site-packages 并且中提琴它有效!

现在这是我的失败还是他们的失败?我下载了 VC++ x86 Redistributable 2015 和 2017,Python 也是 32 位的,而且我使用的是 32 位版本的 OpenCV lib,所以我认为这不是我的问题,这是怎么回事,有人知道吗?

标签: pythonopencvcv2

解决方案


尝试使用 pip 安装?我从来没有遇到过 cv2 的 pip 安装问题。

pip install opencv-python

推荐阅读