一.更换pip的安装源,官方源替换为清华源
永久更换,一劳永逸
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set install.trusted-host https://pypi.tuna.tsinghua.edu.cn
(临时使用 pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple)
安装
pip install opencv-python
但是使用的时候有可能会报这个错误:ImportError: libGL.so.1: cannot open shared object file: No such file or directory
二.继续安装
pip install opencv-python-headless
(可能直接安装这个也可以,保险起见都安上最好)