在使用Python开发过程中,经常要用pip安装软件包,但是直接使用pip install packagename经常慢得要死,而且慢就算了很多时候还下载完成安装失败。
问题原因
pip默认使用的是国外源(https://pypi.org/simple),由于众所周知的原因,访问一般都会很慢。
解决方案
使用国内源。
临时方法
在命令行里面加上 -i https://pypi.tuna.tsinghua.edu.cn/simple
一劳永逸的方法
直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。(这里针对Windows系统)- [global]
- index-url = https://pypi.tuna.tsinghua.edu.cn/simple
- [install]
- trusted-host=mirrors.aliyun.com
复制代码 国内源记录
清华: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/
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |