在我们使用pip安装时,经常会遇到很多问题导致我们pip失败,这里笔者有几个方法
方法一,有时安装超时我们可以设置超时时间
pip --default-timeout=100 install xxx
方法二:更改镜像源,因为默认镜像源是在国外的,我们可以通过更改镜像源来是pip成功
更改镜像源方法
pip install xxxx -i https://pypi.douban.com/simple
下面是国内一些常用的镜像源
阿里云 http://mirrors.aliyun.com/pypi/simple
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple
豆瓣(douban) http://pypi.douban.com/simple
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple
方法三:如果光更改镜像源还不可以,那么我们可以添加一个trust
pip install matplotlib -i https://pypi.douban.com/simple --trusted-host pypi.douban.com