[英]Windows: Python + OpenCV + Qt: “import cv2” gives “dll not found” error
I have a problem when I'm trying to use OpenCV (v3.1.0) in Python (v3.4). 当我尝试在Python(v3.4)中使用OpenCV(v3.1.0)时遇到问题。 To make things more complicated, OpenCV is built with the "contrib" package and Qt support (v5.5).
为了使事情变得更复杂,OpenCV内置了“ contrib”软件包和Qt支持(v5.5)。
This is what I did (this has some pitfalls on it's own, but those are out of the scope of this question): 这就是我所做的(这本身就有一些陷阱,但是这些不在此问题的范围之内):
cmake ( OpenCV 3.1.0 for python 3 ) already took care of copying the "cv2.pyd" to the "your/python/folder/Lib/site-modules" directory. cmake(适用于python 3的OpenCV 3.1.0)已经负责将“ cv2.pyd”复制到“ your / python / folder / Lib / site-modules”目录中。
Now I have the problem that calling "import cv2" from python gives the error " 现在,我遇到的问题是,从python调用“ import cv2”会产生错误“
>>> import cv2
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
ImportError: DLL load failed: Module not found
How can I find out which module is missing and how to solve it? 如何找出缺少的模块以及如何解决?
What you may not want to do is just adding paths that are likely needed to your environment variables . 您可能不想做的只是添加环境变量可能需要的路径 。
There is a way to find out what is missing: 有一个办法,找出哪些是缺失的:
For me, it was the case that python/cv2.pyd searched to all the Qt DLLs in the folder where cv2.pyd is in. 对我来说,是python / cv2.pyd搜索cv2.pyd所在文件夹中的所有Qt DLL的情况。
I just copied them there and that was it. 我只是将它们复制到那里,仅此而已。
For Windows: 对于Windows:
Step 1. Download python installer from https://www.python.org/downloads/ ,install python by double clicking this file and check the option for adding python to PATH as in given image. 步骤1.从https://www.python.org/downloads/下载python安装程序,双击此文件安装python,并按照给定的图像检查将python添加到PATH的选项。
Step 2. Download file "numpy‑1.15.4+mkl‑cp27‑cp27m‑win32.whl" from unofficial site . 步骤2.从非官方站点下载文件“ numpy‑1.15.4 + mkl‑cp27‑cp27m‑win32.whl”。
Go to this file's location open command prompt and type- 转到该文件的位置打开命令提示符,然后键入-
pip install numpy‑1.15.4+mkl‑cp27‑cp27m‑win32.whl
Now go to python IDLE and type: 现在转到python IDLE并输入:
import numpy
It should give no error. 它应该没有错误。
Step 3. Download file "scipy‑1.2.1‑cp27‑cp27m‑win32.whl" from unofficial site . 步骤3.从非官方站点下载文件“ scipy‑1.2.1‑cp27‑cp27m‑win32.whl”。
Go to this file's location open command prompt and type- 转到该文件的位置打开命令提示符,然后键入-
pip install scipy‑1.2.1‑cp27‑cp27m‑win32.whl
Now go to python IDLE and type: 现在转到python IDLE并输入:
import scipy
It should give no error. 它应该没有错误。
step 4 : Download file "opencv_python‑2.4.13.7‑cp27‑cp27m‑win32.whl" from unofficial site . 步骤4:从非官方站点下载文件“ opencv_python‑2.4.13.7‑cp27‑cp27m‑win32.whl”。
Go to this file's location open command prompt and type- 转到该文件的位置打开命令提示符,然后键入-
pip install opencv_python‑2.4.13.7‑cp27‑cp27m‑win32.whl
Now go to python IDLE and type: 现在转到python IDLE并输入:
import cv2
It should give no error, means opencv installed successfully in windows. 它应该没有错误,这意味着在Windows中成功安装了opencv。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.