自动完成对OpenCV的Python的Windows中不工作 [英] Autocomplete for OpenCV-Python in Windows not working

查看:461
本文介绍了自动完成对OpenCV的Python的Windows中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法自动完成在Windows上的OpenCV(Python)的工作。

I cannot get autocomplete working for OpenCV (Python) on Windows.

据阿比德的说明这里 ,我贴在C cv2.pyd文件:\\ Python27 \\ LIB \\网站-packages。

According to Abid's instructions here, I pasted the cv2.pyd file in the C:\Python27\Lib\site-packages.

在Python的code,我输入如下:

In the Python code, I import as follows:

import cv2.cv as cv

我也安装numpy的,它在站点包创建自己的文件夹不同的OpenCV(我已经直接粘贴到站点包)。

I have also installed numpy, and it created its own folder in site-packages unlike OpenCV (which I've pasted directly into site-packages).

通过此设置中,code执行没有任何问题,被称为OpenCV的方法也是如此。

With this setup, the code executes without any problems, even when OpenCV methods are called.

但我一直没能得到自动完成工作。我试图得到它的崇高文字2(与卓异codeIntel)和PyCharm工作。在这两个IDE中,自动完成的作品为numpy的进口,但失败OpenCV的导入。

But I have not been able to get autocomplete to work. I have tried to get it to work on Sublime Text 2 (with SublimeCodeIntel) and PyCharm. In both IDEs, autocomplete works for the numpy import, but fails for the OpenCV import.

我使用OpenCV的2.4.6和Python 2.7(32位)。

I'm using OpenCV 2.4.6, and Python 2.7 (32 bit).

任何可能的解决方案?

推荐答案

它不工作的原因是因为您使用的是 .pyd 文件,该文件是<一个HREF =htt​​p://docs.python.org/2/faq/windows#is-a-pyd-file-the-same-as-a-dll相对=nofollow>基本上相同编译的.dll 。自动完成的工作方式是阅读源的.py 文件,这些文件是纯文本。尝试安装 OpenCV的 和英特尔数学核心函数库的优化 numpy的 从克里斯托夫Gohlke的 Python的扩展包包的Windows 库,这是经常更新,并为任何人谁做任何一种在Windows上的Python科学计算必须使用的资源。请确保您删除 cv2.pyd numpy的目录站点包第一。这些新的软件包将安装在崇高的文本自动完成引擎所需要的的.py 源文件。

The reason it's not working is because you're using a .pyd file, which is essentially the same as a compiled .dll. Autocomplete works by reading the source .py files, which are plain text. Try installing the OpenCV and Intel Math Kernel Library optimized NumPy packages from Christoph Gohlke's Python Extension Packages for Windows repository, which is frequently updated and a must-use resource for anyone who does any kind of scientific Python computing on Windows. Make sure you delete the cv2.pyd and numpy directories from site-packages first. These new packages will install the .py source files needed by the autocomplete engine in Sublime Text.

修改

EDIT

OK,所以我写了上面,因为它运作良好,对很多其他的包。我是一个Python 3的家伙,我从来没有从Gohlke安装OpenCV的,因为它只有Python 2里绑定。阅读@疯狂codeR的<一后href=\"http://stackoverflow.com/questions/18672087/autocomplete-for-opencv-python-in-windows-not-working/18674214?noredirect=1#comment27503953_18674214\">comment下面,我启动了Win7的,而事实上,他是绝对正确的(我真应该早点意识到这一点) - 自OpenCV的是用C / C ++,包括唯一的的.py 文件在Gohlke包 cv.py ,其全部内容如下:

OK, so I wrote the above because it worked well for a bunch of other packages. I'm a Python 3 guy, and I never installed OpenCV from Gohlke because it only has Python 2 bindings. After reading @CrazyCoder's comment below, I booted up Win7, and indeed he's absolutely correct (and I should have realized this before) - since OpenCV is written in C/C++, the only .py file included in the Gohlke package is cv.py, whose entire contents are as follows:

from cv2.cv import *

剩下的就是包含在 cv2.pyd 和一堆的.dll 秒。从 opencv.org 完整的OpenCV的Windows分发是一个291 MB的下载,这将扩展为3 GB,少数的.py 文件有参与建设O​​penCV的,而且都没有任何好自动完成的目的。所以,不幸的是,我不知道是否有此刻你的问题的解决方案。只要保持文档得心应手,或许检查出的 OpenCV的计算机视觉与Python由Packt /奥赖利的,发表在2013年四月祝你好运!

The rest is contained in cv2.pyd and a bunch of .dlls. The full OpenCV Windows distribution from opencv.org is a 291 MB download, which expands to 3 GB, and the few .py files in there are involved in building OpenCV, and aren't any good for autocomplete purposes. So, unfortunately, I don't know if there's a solution to your problem at the moment. Just keep the docs handy, and perhaps check out OpenCV Computer Vision with Python from Packt/O'Reilly, published in April 2013. Good luck!

这篇关于自动完成对OpenCV的Python的Windows中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆