如何安装libavformat.so.56和libavformat.so.57?

时间:2018-06-10 11:09:13

标签: python opencv package anaconda libavformat

我使用pip在Anaconda虚拟环境中使用以下命令安装opencv3。

install opencv-python

我成功安装了它,因为我可以看到pip列表中的包。

(olfatf)rover@rover_pi:/usr/lib/arm-linux-gnueabihf $ pip list | grep opencv
opencv-python          3.4.0.14  

但是,当我导入cv2时,我收到以下错误:

(olfatf)rover@rover_pi:/usr/lib/arm-linux-gnueabihf $ python
Python 3.4.3 |Continuum Analytics, Inc.| (default, Aug 21 2015, 00:53:08) 
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.conda/envs/olfatf/lib/python3.4/site-packages/cv2/__init__.py", line 3, in <module>
    from .cv2 import *
ImportError: libavformat.so.56: cannot open shared object file: No such file or directory

我查看了/usr/lib/arm-linux-gnueabihf目录,发现:

(olfatf)rover@rover_pi:/usr/lib/arm-linux-gnueabihf $ ls | grep libavformat
libavformat.a
libavformat.so
libavformat.so.57
libavformat.so.57.56.101

我可以看到那里,我有版本57,但缺少版本56。 我在网上做过研究,人们建议我应该安装libavformat-dev

(olfatf)rover@rover_pi:/usr/lib/arm-linux-gnueabihf $ sudo apt-get install libavformat-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libavformat-dev is already the newest version (7:3.2.10-1~deb9u1+rpt1).

但它说包已经存在。我也尝试过安装ffmpeg。

(olfatf)rover@rover_pi:/usr/lib/arm-linux-gnueabihf $ sudo apt-get install ffmpeg
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ffmpeg is already the newest version (7:3.2.10-1~deb9u1+rpt1).

但它说包已经存在。

如何获得56版本? 我使用Raspberry Pi Strech

1 个答案:

答案 0 :(得分:0)

经过20个小时的研究,我从源头编译解决了这个问题。我用这个tutorial在Anaconda Environmnent上安装opencv