I need OpenCV 2 for a legacy program, specifically OpenCV 2.4.9.1. I have attempted to install python-opencv=2.4.9.1+dfsg-1.5ubuntu1 and libopencv-dev=2.4.9.1+dfsg-1.5ubuntu1. The former appears to install, and when I try to install the latter, having removed its OpenCV 3 equivalent (which has recently become the default), Ubuntu retains some unmet dependency problems which seem to arise from removing OpenCV 3. I have attempted to install libopencv-legacy-dev, which appears to install, but then I am met with the standard OpenCV wrong version error: ImportError: No module named cv2.


~ sudo apt install python-opencv=2.4.9.1+dfsg-1.5ubuntu1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-opencv is already the newest version (2.4.9.1+dfsg-1.5ubuntu1).
0 to upgrade, 0 to newly install, 0 to remove and 12 not to upgrade.

~ sudo apt install libopencv-dev=2.4.9.1+dfsg-1.5ubuntu1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies.
 libopencv-dev : Depends: libopencv-core-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-ml-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-imgproc-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-video-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-objdetect-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-highgui-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-calib3d-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-flann-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-features2d-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-legacy-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-contrib-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-ts-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-photo-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-videostab-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-stitching-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-gpu-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-superres-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv-ocl-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv2.4-java (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libopencv2.4-jni (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libcv-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libhighgui-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
                 Depends: libcvaux-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but 2.4.9.1+dfsg-1.5ubuntu1.1 is to be installed
E: Unable to correct problems, you have held broken packages.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.