树莓派安装openCV-python

树莓派目前不支持OpenCV4,建议安装 opencv_python-3.4.6.27-cp37-cp37m-linux_armv7l.whl

首先安装依赖包:

#养成更新的好习惯
sudo apt-get update
sudo apt-get upgrade

#依赖包
sudo apt-get install libhdf5-dev libhdf5-serial-dev
sudo apt-get install libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev

安装OpenCV:

pip3 install opencv-python==3.4.6.27

结果会发现下载速度非常慢,甚至直接断流,还可能出现找不到对应版本的错误,让人很烦,个人认为比较好的解决办法是到对应网站直接下载软件包,然后本地pip安装。

OpenCV3.4.6.27下载地址

本地安装:

pi@raspberrypi:~/Desktop $ pip3 install opencv_python-3.4.6.27-cp37-cp37m-linux_armv7l.whl
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing ./opencv_python-3.4.6.27-cp37-cp37m-linux_armv7l.whl
Requirement already satisfied: numpy>=1.16.2 in /usr/lib/python3/dist-packages (from opencv-python==3.4.6.27) (1.16.2)
Installing collected packages: opencv-python
Successfully installed opencv-python-3.4.6.27

测试安装是否成功:

pi@raspberrypi:~/Desktop $ python
Python 3.7.3 (default, Dec 20 2019, 18:57:59) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> 

OK!

你可能感兴趣的:(树莓派,opencv,python,pip)