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

asheeshr picture asheeshr · Dec 15, 2012 · Viewed 15k times · Source

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 ?

Answer

asheeshr picture asheeshr · Jan 3, 2013

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