最近使用Pip安装Python的第三方库时,下载速度再次击穿我的认知,于是有了这篇的短文……
国内pip源镜像
用pip安装时,默认使用的是国外源文件,在国内使用下载速度会不稳定,有时可能只有几十KB每秒。因此需要考虑如何将pip源设置为国内镜像。
阿里云
http://mirrors.aliyun.com/pypi/simple/
豆瓣
http://pypi.douban.com/simple/
清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学
http://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学
http://pypi.hustunique.com/simple/
山东理工大学
http://pypi.sdutlinux.org/simple/
Pip国内镜像设置
设置为临时
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
示例:使用清华源下载cx-Oracle,如下图,下载速度2.0MB/s。
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple cx-Oracle
设置为默认
pip config set global.index-url http://mirrors.aliyun.com/pypi/simplepip config set global.trusted-host mirrors.aliyun.com
直接输入上述两行命令,即可设置pip源默认为清华源,如下图:
若对你有所帮助,欢迎大家评论、留言,若感兴趣 。
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!