trying to overwrite '/usr/bin/opencv_haartraining', which is also in package libopencv2.3-bin 2.3.1+svn6514+branch23-12~oneiric

http://www.iasptk.com/ubuntu-fix-broken-package-best-solution

After trying

sudo dpkg --configure -a

and

sudo apt-get install -f

the problem of a broken package still exist the solution is to edit the dpkg status file manually.

sudo nano /var/lib/dpkg/status  

(you can use vim instead of nano)

Locate the corrupt package, and remove the whole block of information about it and save the file.


Command OP tried:

sudo apt-get install -f

Error report for the above command:

dpkg: error processing /var/cache/apt/archives/libcv-dev_2.1.0-7build1_amd64.deb (--unpack):
trying to overwrite '/usr/bin/opencv_haartraining', which is also in package
libopencv2.3-bin 2.3.1+svn6514+branch23-12~oneiric
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/libcv-dev_2.1.0-7build1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

From the above error report it was clearly shown that, while running sudo apt-get install -f command dpkg tries to extract and install /var/cache/apt/archives/libcv-dev_2.1.0-7build1_amd64.deb file.Installation requires to place opencv_haartraining file on the /usr/bin directory.

But it was shocked on seeing the same /usr/bin/opencv_haartraining file on the /usr/bin directory and produced the error, because this file had already been placed during libopencv2.3-bin package installation.

Solution for the above error is to remove the already installed libopencv2.3-bin package by running,

sudo dpkg -P libopencv2.3-bin

And then do,

sudo apt-get install -f

Now the above command automatically tries to install /var/cache/apt/archives/libcv-dev_2.1.0-7build1_amd64.deb package and it can install the package successfully because now there was no block.


first remove the libcv-dev package

sudo dpkg -r libcv-dev

then

sudo apt-get install -f

the

sudo apt-get update