首先更换源,见https://www.cnblogs.com/cc-xiao5/p/11233256.html,记得更新库
然后依次进行以下操作
一、安装Python-dev
sudo apt-get install aptitude sudo aptitude install python-dev
二、安装pip3
sudo apt-get install python3-pip sudo pip3 install --upgrade pip
三、安装CV2
先sudo apt-get update更新然后在安装即可
sudo pip3 install opencv-python
最后顺带安装numpy, scipy, matplotlib 记得更改权限
pip3 install numpy pip3 install scipy pip3 install matplotlib pip3 install pandas
如果系统有python2和python3,将python3设置为默认
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150