Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing OpenCV for Python in Ubuntu 12.04. No module present in dist-packages or site-packages?

Following the steps given here, i have completed the installation process, however Python (IDLE) is giving me an ImportError. For which the guide suggests :

Python may return to you an error like "No module named cv" The trouble is that the python module is installed in /usr/local/lib/python2.6/site-packages. But, on Debian and on Ubuntu, Python only looks in /usr/local/lib/python2.6/dist-packages

You can fix it using three ways (Use only one of those, the first is the best):

  1. move the cv.so file from the site-packages to the dist-packages:

    sudo mv /usr/local/lib/python2.6/site-packages/cv.so /usr/local/lib/python2.6/dist-packages/cv.so

However, both the site-packages as well as dist-packages, for both 2.7 and 3.2 are empty.

What went wrong and how do i solve it ?

like image 686
asheeshr Avatar asked Dec 15 '12 13:12

asheeshr


People also ask

How do I fix No module named cv2?

The Python "ModuleNotFoundError: No module named 'cv2'" occurs when we forget to install the opencv-python module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install opencv-python command.

Where is OpenCV installed Ubuntu?

By default OpenCV will be installed to the /usr/local directory, all files will be copied to following locations: /usr/local/bin - executable files.


1 Answers

I solved the problem by installing all the packages and dependencies again using the Software Center. OpenCV Python bindings are available for OpenCV 2.3 and Python 2.7 directly from the software center which I used the second time.

OpenCv python bindings for 3.2 are not available for 12.04. They are being developed for Raring (Ubuntu 13.04) only. Hence, the solution is to use either backports, or to use OpenCv on Python 2.7

Backports also have a problem as they are available only for 32 bit OS systems and not 64 bit.

So, the only safe and stable way to run OpenCV Python on Ubuntu seems to be using OpenCV 2.3 on Python 2.7

like image 153
asheeshr Avatar answered Sep 28 '22 05:09

asheeshr