pip更换镜像源

前言

python的pip安装库很慢,因为它默认的镜像源是国外的,将镜像源换成国内的就很快了,下面介绍怎么更换国内镜像源。

正文

国内比较好的镜像源有以下这些:

  • 阿里云 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/

如果是想临时更换镜像源,通过以下命令:

pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple

在后面-i接镜像源就可以了。

临时更换比较麻烦,建议一劳永逸,把国内的镜像源设成默认就可以了,不过要升级 pip 到最新的版本 (>=10.0.0) 。

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

 

posted @ 2020-06-08 12:25  Marvin-wen  阅读(3519)  评论(0编辑  收藏  举报