Python import cv error on OpenCV 3.0.0 (no error for import cv2) [closed]

asked 2015-08-21 10:43:51 -0500

richik gravatar image

I am using a Windows 10 machine with Python 2.7.x and OpenCV 3.0.0 installed and both work fine. I followed the official link for installation of the same along with numpy and matplotlib. I get an error saying:

ImortError: No module named cv

when I try to run the following code:

import cv2
import numpy as np
import cv

def diceroll():
    rng = cv.RNG(np.random.randint(1,10000))
    print 'The outcome of the roll is:'
    print int(6*cv.RandReal(rng) + 1)


I have also tried using instead of cv(and not use import cv) but then I get an error saying:

AttributError: 'module' object has no attribute 'cv'

Implying cv2 does not have cv attribute. Is there a way I can get it to work? I have just followed the link given above and not appended any python path or set environment variables for openCV

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-04 14:10:07.363506



yes, the old cv or api got removed entirely in opencv3. (not your error)

berak gravatar imageberak ( 2015-08-21 11:48:55 -0500 )edit

@berak is there a way I can use the RNG function with this setup? I am open to installing additional packages.

richik gravatar imagerichik ( 2015-08-22 06:27:01 -0500 )edit

no real idea, unfortunately. there seems to be no such thing as cv2.RNG.

can't you use something from numpy.random ?

berak gravatar imageberak ( 2015-08-22 06:50:49 -0500 )edit

Sure, I will use something else . Thanks barak :)

richik gravatar imagerichik ( 2015-08-22 11:35:37 -0500 )edit