Python2.7.1导入OpenCV2.2报错Windows XP
我在使用 OpenCV2.2 和 Python2.7.1(应该兼容)时遇到一些问题。我已将 OpenCV 安装到 D:\OpenCV2.2PreCom\
,并将 D:\OpenCV2.2PreCom\Python2.7\Lib\site-packages
路径添加到 sys.path
以及环境变量 PYTHONPATH。
我还确保将 D:\OpenCV2.2PreCom\bin
路径添加到 Path 环境变量中。但是,当我尝试通过键入来访问 cv.pyd
文件(位于 D:\OpenCV2.2PreCom\Python2.7\Lib\site-packages\
中)时'import cv',
我得到一个 importerror
:
IDLE 看起来像这样:
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import sys
>>> sys.path.append('D:\OpenCV2.2PreCom\Python2.7\Lib\site-packages')
>>> import cv
Traceback (most recent call last):
File "<pyshell#64>", line 1, in <module>
import cv
ImportError: DLL load failed: The specified module could not be found.
>>>
那么我还能尝试什么让 Python 导入 OpenCV?
谨致问候。
I'm having some trouble using OpenCV2.2 with Python2.7.1 (which should be compatible). I've installed OpenCV to D:\OpenCV2.2PreCom\
, added the D:\OpenCV2.2PreCom\Python2.7\Lib\site-packages
path to sys.path
as well as to the environment variable PYTHONPATH.
I've also made sure the D:\OpenCV2.2PreCom\bin
path is added to the Path environment variable. However, when I try to access the cv.pyd
file (which is in D:\OpenCV2.2PreCom\Python2.7\Lib\site-packages\
) by typing 'import cv',
I get an importerror
:
The IDLE looks like this:
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import sys
>>> sys.path.append('D:\OpenCV2.2PreCom\Python2.7\Lib\site-packages')
>>> import cv
Traceback (most recent call last):
File "<pyshell#64>", line 1, in <module>
import cv
ImportError: DLL load failed: The specified module could not be found.
>>>
So what else can I try to make Python import OpenCV?
With kind regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不是 Windows 用户,但似乎 Python 模块找不到 DLL。这不是
PYTHONPATH
的问题。你是安装了还是直接解压了?尝试使用安装程序安装它,它应该负责将 DLL 定位在正确的路径中。
Not a Windows user, but seems that the Python module cannot find the DLL. It is not a problem of
PYTHONPATH
.Did you install it or just unpack it? Try installing it with the installer, it should take care of positioning the DLL in the right path.
你能尝试转义反斜杠吗?试试这个:
Can you try escaping the backslashes? Try this:
您应该将
D:\OpenCV2.2PreCom\Python2.7\Lib\site-packages
的内容(里面应该有两个文件)复制到您的 python 安装的站点包中,默认是是C:\Python2.7\Lib\site-packages
并转义您的后睫毛或将其替换为/
You should copy the content of
D:\OpenCV2.2PreCom\Python2.7\Lib\site-packages
(there should be two files inside ) in the site-packages of your python install, the default one beingC:\Python2.7\Lib\site-packages
and escape you back lashes or replace them with/