python-----pip安装源选择(亲测有效)


Python使用pip方法安装第三方包时,需要从 https://pypi.org/ 资源库中下载,但是会面临下载速度慢,甚至无法下载的尴尬。

使用国内镜像自然是个好方法:

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

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

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

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

我们可以直接在 pip 命令中使用 -i 参数来指定镜像地址,例如:

使用清华镜像源安装 numpy 包:pip3 install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple

永久生效需要做下配置:

linux:在用户目录下新建.pip/pip.conf,并编辑

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple 

[install]

trusted-host = https://pypi.tuna.tsinghua.edu.cn

 

windows:在用户目录下新建pip.ini,并编辑内容同linux

比如我的:C:\Users\Administrator\AppData\pip\pip.ini

内容同linux:

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple 

[install]

trusted-host = https://pypi.tuna.tsinghua.edu.cn

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM