pip安装软件的时候,常常会遇到模块的下载速度奇慢无比。后来发现能够临时使用镜像地址ubuntu
例如:bash
sudo pip install -i http://pypi.douban.com/simple/ paramiko # 使用豆瓣的pip镜像
有次找ubuntu镜像源的时候,发现国内的镜像源不少有pip的镜像。源站已经很是的强大完善了,感受错过了好几亿似的。阿里云
例如:url
http://mirrors.ustc.edu.cn/
http://mirrors.aliyun.com/
https://mirrors.tuna.tsinghua.edu.cn/
不废话了,直接上方法。code
sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple sphinx
[global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com
#!/bin/bash #auto change pip mirror PIPPATH=$HOME/.pip PIPFILE=pip.conf ROOT_UID=0 ROOT_LOGIN=-1 #create pip conf file and write configer info 2 file createPipConf(){ cat >> $PIPPATH/$PIPFILE <<EOF [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com [list] format=columns EOF echo "create $PIPFILE success!" } #if pip path not exists create it checkPipPath(){ if [ ! -d $PIPPATH ] ; then echo "will create $PIPPATH" mkdir -p $PIPPATH fi } #must login as normal user if [ "$(id -u )" -eq "$ROOT_UID" ];then echo "you should login as normal user!" exit $ROOT_LOGIN else checkPipPath #if pip.conf exists ,bakup and create a new configer file if [ -f $PIPPATH/$PIPFILE ];then echo "$PIPFILE exists,will rename 2 $PIPFILE.bak and create a new file!" mv $PIPPATH/$PIPFILE $PIPPATH/$PIPFILE.bak createPipConf else echo "will crate pip.conf file!" createPipConf fi fi exit 0