python开发者经过国内镜像安装pip包

对于Python开发用户来说,PIP安装软件包是屡见不鲜。但国外的源下载速度实在太慢,浪费时间。并且常常出现下载后安装出错问题。因此把PIP安装源替换成国内镜像,能够大幅提高下载速度,还能够提升安装成功率。linux

国内源:

新版ubuntu要求使用https源,要注意。ubuntu

清华:https://pypi.tuna.tsinghua.edu.cn/simplewindows

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

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

华中理工大学:http://pypi.hustunique.com/阿里云

山东理工大学:http://pypi.sdutlinux.org/ url

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

 

临时使用:

能够在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple

例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装pyspider库。code

 

要配制成默认的话,须要建立或修改配置文件(linux的文件在~/.pip/pip.conf,windows在%HOMEPATH%\pip\pip.ini),修改内容为:pyspider

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

这样在使用pip来安装时,会默认调用该镜像。

 

还有一个小技巧,就是把全部要安装的包写在一个文件里面,好比requirement.txt(每一个包写一行,顶行头写),而后pip安装的时候只须要加参数“-r  requirement.txt”便可。

相关文章
相关标签/搜索