1.修改更新源
sudo vi /etc/apt/sources.list
科大源:
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
清华源:
deb https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
deb-src https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
阿里云:
deb http://mirrors.aliyun.com/raspbian/raspbian/ stretch main contrib non-free rpi
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ stretch main contrib non-free rpi
sudo vi /etc/apt/sources.list.d/raspi.list
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ stretch main ui
2.更新系统
sudo apt-get update
sudo apt-get upgrade
3.更新基础库
sudo apt-get install libjpeg-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libtiff5-dev
sudo apt-get install libpng12-dev
sudo apt-get install libqtgui4 libqt4-test
sudo apt-get install libjasper-dev
如果报依赖错误,可以跳过,暂时不影响。
sudo apt-get update
sudo apt-get upgrade
4.安装python-opencv
sudo apt-get install python-opencv
报以下错误就是因为基础库或python-opencv没有安装
libhdf5_serial.so.103: cannot open shared object file: No such file or directory
5.检查opencv是否安装成功
pi@raspberrypi:~ $ python
Python 2.7.16 (default, Apr 6 2019, 01:42:57)
[GCC 8.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'2.4.9.1'
>>>