libavcodec.so.56 not found when running software compiled with opencv

17,598

Solution 1

Just install ffmpeg by typing:

sudo apt-get install -y ffmpeg

And you get this files:

  1. /usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so
  2. /usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so.56
    Just copy /usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so.56 to /usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so.56

Solution 2

I will post here how I got resolved the same problem in my raspberry pi 3 when installing opencv for python, hopefully someone same the time.

1) Make sure you don't have opencv versions other than "python-opencv" by following command.

sudo dpkg --get-selections | grep cv3

If above shows an output uninstalled it as follows

dpkg -r opencv3.1

"opencv3.1" should be replaced by your version.

2) Then follow following step to install "python-opencv"

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-setuptools
sudo apt-get install python-pip
sudo apt-get install ipython python-opencv python-scipy python-numpy python-pygame

this blog explains installation process

Share:
17,598
Simon Garnier
Author by

Simon Garnier

Updated on June 04, 2022

Comments

  • Simon Garnier
    Simon Garnier almost 2 years

    I just upgraded my computer to Ubuntu 16.04. Now every time I try to run software compiled with opencv, I get the following error:

    libavcodec.so.56: cannot open shared object file: No such file or directory

    Looking around /usr/lib/x86_64-linux-gnu/, I can find libavcodec.so, but not libavcodec.so.56.

    When trying to run sudo apt-get install libavcodec56, I get:

    Package 'libavcodec56' has no installation candidate

    I've scoured the internet in search of an answer, but could not find anything at this point. Any help with solving this annoying problem will be very much appreciated.