import cv2 works but import cv2.cv as cv not working
Asked Answered
T

1

10

I think the sys path is correct, cv.pyd and cv.pyd reside in c:\OpenCV2.3\build\Python\2.7\Lib\site-packages.

>>> import sys
>>> sys.path
['', 'C:\\Python27\\Lib\\idlelib', 'C:\\Python27\\lib\\site-packages\\pil-1.1.7-py2.7-win32.egg',     'C:\\Python27\\lib\\site-packages\\cython-0.17-py2.7-win32.egg', 'C:\\Python27\\lib\\site-packages\\pip-1.2-py2.7.egg', 'c:\\OpenCV2.3\\build\\Python\\2.7\\Lib\\site-packages', 'C:\\Python27\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\IPython\\extensions']

And import cv or cv2 seems to be ok but import cv2.cv not

>>> import cv
>>> import cv2.cv as cv

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    import cv2.cv as cv
ImportError: No module named cv
>>> import cv2
>>> cv.NamedWindow("camera", 1)

...

What could be the reason of the ImportError?

Tropism answered 6/9, 2012 at 2:10 Comment(1)
Sorry guys, I just found that in OpenCV2.3 the cv2 module doesn't have cv attrib ...Tropism
T
1

I had the same issue.This was an issue with OpenCV Engine.Download OpenCV engine from https://github.com/thumbor/opencv-engine/releases/tag/1.0.1 and save it as engine.py in \Python27\Lib\site-packages.use cv2.cv instead of cv2.cv as cv.

Tizes answered 30/6, 2016 at 8:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.