问题描述
我已经下载了OpenCV2.1和Python2.6.
I have downloaded OpenCV2.1 and Python2.6.
当我尝试先使用sys.path.append("C:\OpenCV2.1\Python2.6\Lib\site-packages")
然后import cv
尝试import cv
时,它会告诉我ImportError: DLLload failed.
.
when i try to import cv
using sys.path.append("C:\OpenCV2.1\Python2.6\Lib\site-packages")
and then import cv
, it tells me ImportError: DLLload failed.
.
我尝试了上一个线程中给出的解决方案,将上述路径中的两个文件复制到C:\Python26\Lib\site-packages
,但是我仍然不能import cv
.
I have tried the solutions given in previous thread to copy the two files in the above path to C:\Python26\Lib\site-packages
, but i still can't import cv
.
是因为我错过了安装后的一些步骤吗?系统找不到模块cv
的原因可能是什么?
Is it because I missed out doing some steps after installing? What could be the reasons to why the system cannot find the module cv
?
推荐答案
似乎找不到OpenCV DLL.您是否将OpenCV的bin目录添加到您的PATH
和"C:\OpenCV2.1\bin"
中?
The OpenCV DLLs seem not to be found. Did you add OpenCV's bin directory to your PATH
, "C:\OpenCV2.1\bin"
in your case?
使用Python包装器
To use the Python wrappers
sys.path.append("C:\OpenCV2.1\Python2.6\Lib\site-packages")
import cv
应该起作用,并将cv.lib
和cv.pyd
复制到您的C:\Python26\Lib\site-packages
(假设您已将Python安装到C:\Python26
).
should work, as well as copying cv.lib
and cv.pyd
to your C:\Python26\Lib\site-packages
(assuming you installed Python to C:\Python26
).
但是那些包装器必须找到应该包装的DLL.因此,请确保它们在Python可以找到它们的路径中.
But those wrappers have to find the DLLs they should wrap. So make sure, they are in a path Python can find them.
也许这个问题在Windows 7上为Python 2.7安装OpenCV 可能会有所帮助,尤其是 Gia Thuy的他在回答中提到的日记帖子.尽管他使用Python 2.7和OpenCV 2.2,但过程仍然相同.
Maybe this question Installing OpenCV on Windows 7 for Python 2.7 may help, especially Gia Thuy's journal post he mentions in his answer. Although he uses Python 2.7 and OpenCV 2.2, the procedure remains the same.
这篇关于无法在OpenCV2.1上导入简历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!