0

I have got a python code from open source community where it imports cv as well as cv2. After installing opencv using conda 'import cv2' resolved. But still I have issue with 'import cv', where it shows 'ImportError: No module named cv'.

Few other things I have tried: 1. sudo apt-get install python-opencv 2. pip install opencv 3. import cv2.cv as cv

Can any one help me how to resolve "No module named cv"? Note that I am using python version 2.7.13

In my code I am using as below:

import cv2
import cv

And getting the following error:

    import cv
ImportError: No module named cv
Asis Patra
  • 69
  • 1
  • 9
  • Could you show us the import line of the code? also according to [this](https://pypi.python.org/pypi/opencv-python) "pip install opencv-python" allow you to use "import cv2". Also [this question](https://stackoverflow.com/questions/32048313/cannot-import-cv-on-opencv2) may help you. Edit: Also this [other question](https://stackoverflow.com/questions/25215102/installing-opencv-for-python-on-ubuntu-getting-importerror-no-module-named-cv2) (older) may have some information for you (they used from from cv2.cv import *). – Eric Godard Aug 30 '17 at 06:49
  • 4
    Possible duplicate of [ImportError: No module named cv2.cv](https://stackoverflow.com/questions/39534496/importerror-no-module-named-cv2-cv) – api55 Aug 30 '17 at 06:52
  • @EricGodard I have added the code segment and error too. Also tried 'from cv2.cv import *' which shows the following error: from cv2.cv import * ImportError: No module named cv – Asis Patra Aug 30 '17 at 09:10
  • since version 3 `cv` was removed from `cv2` – magicleon94 Aug 30 '17 at 09:11
  • @magicleon, I am using opencv version 2.4.9.1, I have used the following command to get version 'pkg-config --modversion opencv' – Asis Patra Aug 30 '17 at 10:31
  • The `cv` module has been removed in OpenCV 3+. What are you trying to use it for? You likely don't need it. – alkasm Aug 30 '17 at 11:25
  • @AlexanderReynolds, I am trying to access cv.CV_CAP_PROP_FPS – Asis Patra Aug 30 '17 at 11:50

1 Answers1

0

The cv module was removed actually before OpenCV 3.0. Regardless, most things accessible through the cv module are still accessible. The cv.CV_CAP_PROP_FPS setting is now cv2.CAP_PROP_FPS.

Basically, the constants given by CV_XXX_XXX used to be accessible through the old cv module via cv2.cv.CV_XXX_XXX but now it's not necessary---just remove the prepended CV_ and use the cv2 module.

alkasm
  • 22,094
  • 5
  • 78
  • 94