您的位置:首页 > 编程语言 > Python开发

【python】包管理工具pip的国内源站点使用

2017-11-28 21:33 681 查看
注:今天在使用pip安装第三方包时,第一次遇到无法连接到pypi.python.org 站点,即包的来源。

CMD下执行ping pypi.python.org

后发现丢包率特别大,而且我发现这个这个网站貌似不是国内的网站,然后我就去找了找国内有没有pip站点,找了一下果然有,如下:

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

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

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

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

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

使用方法:

在pip下,执行以下命令,如下载request包

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

会发现,网速果然比一起啊快了好多

如果出现这是未信任的源,修改上述命令,如下:

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

- -trusted-host pypi.tuna.tsinghua.edu.cn

如果想使用其为默认源

windows下可修改%HOMEPATH%\pip\pip.ini文件

修改内容为:

[global]

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

[install]

trusted-host=pypi.tuna.tsinghua.edu.cn

解决了痛点,标记一下,供大家使用!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: