LMSouq
server-admin Open

Installing OpenCV for Python on Ubuntu, getting ImportError: No module named cv2.cv

RO
robm
1 month ago
3 views
Problem Description
I have an Ubuntu 14.04 system, on which I want to install OpenCV and use it with Python 2.x. I installed OpenCV using the instructions here: [https://help.ubuntu.com/community/OpenCV][1] The install seemed to run properly, no errors, the script ended with output OpenCV 2.4.9 ready to be used When I try to run the sample Python script, I get the following: $ python opencv.py Traceback (most recent call last): File "opencv.py", line 1, in <module> from cv2.cv import * ImportError: No module named cv2.cv I suspect I know why, I just don't know how to fix it. OpenCV installed to the current directory I was in when I ran the install script, it's a subdirectory of my home folder. Others who get this import error after install seem to be having a path issue, and have luck adding this to their code: import sys sys.path.append('/usr/local/lib/python2.7/site-packages') or updating their PYTHONPATH with that same directory. I tried adding that code, it doesn't make a difference. I don't see any files in the "site-packages" directory. Should I have done the install in that directory? I imagine the installation instructions would have spelled that out. I suspect that my problem has to do with Python not finding the OpenCV install, but I'm not sure how to proceed. Please help me get a usable install of OpenCV as simply as possible. [1]: https://help.ubuntu.com/community/OpenCV

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base