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

来源:互联网 发布:linux修改分区大小 编辑:程序博客网 时间:2024/06/08 09:23

注:今天在使用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

解决了痛点,标记一下,供大家使用!