ImportError: libavcodec.so.56: 无法打开共享对象文件: 没有这样的文件或目录

ImportError: libavcodec.so.56: 无法打开共享对象文件: 没有这样的文件或目录

我用 pacman 安装了 opencv,当我尝试导入 opencv 时,出现以下错误:

>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libavcodec.so.56: cannot open shared object file: No such file or directory

我该如何修复这个错误?

编辑

sudo pacman -Ss libav
extra/gst-libav 1.4.4-1 [installed: 1.4.1-1]
    Gstreamer libav Plugin
extra/libavc1394 0.5.4-2 [installed]
    A library to control A/V devices using the 1394ta AV/C commands.
community/ffms2 2.20-2 [installed]
    A libav/ffmpeg based source library and Avisynth plugin for easy frame
    accurate access

答案1

这意味着您没有安装正确的库。尝试使用 进行搜索pacman -Ss libav

在 OpenSuSE 上,这部分libavcodec52内容表示它与ffmpeg.检查是否安装了ffmpegat以及依赖项应该拉入 libavcodec。

编辑

读完拱门后文档,看起来确实ffmpeg提供了libavcodec要求。

答案2

检查 ffmpeg 软件包是否安装和版本时,centOS 上也遇到同样的问题:

 #/usr/local/bin/ffmpeg

/usr/local/bin/ffmpeg: error while loading shared libraries: libavdevice.so.56: cannot open shared object file: No such file or directory

或者

# ldd `which ffmpeg`
    linux-vdso.so.1 =>  (0x00007fffb32d8000)
    libavdevice.so.56 => not found
    libavfilter.so.5 => not found
    libavformat.so.56 => not found
    libavcodec.so.56 => not found
    libpostproc.so.53 => not found
    libswresample.so.1 => not found
    libswscale.so.3 => not found
    libavutil.so.54 => not found
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f75f2ef8000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f75f2c74000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f75f28df000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f75f3126000)

解决方案:

现在,检查库路径,打开ld.so.conf

# vim /etc/ld.so.conf

include ld.so.conf.d/*.conf
/usr/local/lib
/usr/lib

最后保存退出:wq!

现在,使用相同的命令检查,

# ffmpeg -v
ffmpeg version N-73873-gcee7acf-syslin Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
  configuration: --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --extra-libs=-lx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include/ --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslin --enable-libass --enable-libvpx --enable-zlib --enable-gpl
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 50.101 / 56. 50.101
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 25.100 /  5. 25.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100

相关内容