visual-studio - Python OpenCV: 奇怪的自动补全问题
巴扎黑
巴扎黑 2017-04-18 10:33:45
0
2
1209

当我使用pip将OpenCV安装好之后,使用visual-studio编写代码时,出现了一个奇怪的问题。使用import cv2导包后,当我输入cv2.时,自动补全并未提示OpenCV内部的函数,而是出现cv2sysos

当我紧接着前一个cv2之后再输入一个cv2后,自动补全才可以正常地补全OpenCV内部的函数。但是大家应该知道,使用import导包后,使用其内部函数时,只需使用一次包名就可使用其中的函数,所以每次写完代码,我还得将多余的cv2删掉,很是麻烦。

我在网上搜索过多次,并未找到解决方法。我曾今怀疑是visual-studio的PTVS的缘故,可是有同学使用的pycharm也出现了同样的错误。所以我觉得可能是pip的原因,不过我并不知道该如何解决,希望有大神相助。

巴扎黑
巴扎黑

reply all(2)
黄舟

This problem has been solved so far.
In the above question, I used pip to install python-opencv online. After installation, pip created a folder CV2 in Lib->site-packages under the python installation path, which means python-opencv was installed in Lib->site-packages->CV2; and then I switched to a third-party offline installation package for installation, in which opencv-python was installed under Lib->site-packages, and No additional folders are created. With the latter, the above problems will not occur. Therefore, I speculate that the above problem is caused by pip installing python-opencv online.
But I don’t understand why this is happening now.
I checked many similar questions on the Internet, and many of them encountered problems that could not be completed. I think they may have encountered the same problem as me, but they didn't write another onecv2, so they couldn't complete it.

PHPzhong

Who should bear the blame==

Not sure why, I can only help you reduce the number of times you delete cv2

from cv2 import cv2
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template