Python2.7.1导入OpenCV2.2报错Windows XP

发布于 2024-10-27 22:47:01 字数 997 浏览 0 评论 0原文

我在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

纵性 2024-11-03 22:47:01

不是 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.

疧_╮線 2024-11-03 22:47:01

你能尝试转义反斜杠吗?试试这个:

>>>> sys.path.append('D:\\OpenCV2.2PreCom\\Python2.7\\Lib\\site-packages')

Can you try escaping the backslashes? Try this:

>>>> sys.path.append('D:\\OpenCV2.2PreCom\\Python2.7\\Lib\\site-packages')
陌路终见情 2024-11-03 22:47:01

您应该将 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 being C:\Python2.7\Lib\site-packages and escape you back lashes or replace them with /

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文