我使用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版本?我用的是树莓皮街
发布于 2018-06-11 13:42:13
经过20个小时的研究,我从源头上解决了这个问题。我使用这个教程在Anaconda上安装opencv
https://stackoverflow.com/questions/50783047
复制相似问题