pip安装CV2(从清华这边的镜像去安装opencv库。)

运行猫狗分类代码出现ModuleNotFoundError: No module named 'cv2'

原因是运行到import cv2时,没有安装cv2,No module named 'cv2', 需要pip 安装,然后就能用import cv2了

对于Python开发用户来讲,PIP安装软件包是家常便饭。但国外的源下载速度实在太慢,浪费时间。而且经常出现下载后安装出错问题。所以把PIP安装源替换成国内镜像,可以大幅提升下载速度,还可以提高安装成功率。

国内源:

新版ubuntu要求使用https源,要注意。

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/ 

豆瓣:http://pypi.douban.com/simple/

临时使用:

可以在使用pip3的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple

例如:pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python,这样就会从清华这边的镜像去安装opencv库。


我是实操时使用的:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python 最后问题得以解决


详情参照:https://blog.csdn.net/qq_43176116/article/details/90370859

你可能感兴趣的:(pip安装CV2(从清华这边的镜像去安装opencv库。))