#!/bin/bash function sets() { mkdir /root > /dev/null 2>&1 mkdir /root/.pip > /dev/null 2>&1 mv /root/.pip/pip.conf /root/.pip/pip.conf.bak > /dev/null 2>&1 cat << EOF >> /root/.pip/pip.conf [global] timeout = 60 index-url = $1 EOF } getopts :s: OPT if [ ! -n "$OPTARG" ];then echo "You can use -s with: tuna|ali|ustc|douban to use different source" echo "Use Default Setting: Douban Pypi" sets "https://pypi.douban.com/simple" elif [ "$OPTARG" == "tuna" ];then echo "Use Tsinghua Pypi" sets "https://pypi.tuna.tsinghua.edu.cn/simple" elif [ "$OPTARG" == "ali" ];then echo "Use Aliyun Pypi" sets "https://mirrors.aliyun.com/pypi/simple" elif [ "$OPTARG" == "ustc" ];then echo "Use USTC Pypi" sets "https://pypi.mirrors.ustc.edu.cn/simple" fi echo "The original source has been move to pip.conf.bak"
为了更方便的为国内的服务器更换Python pip源(就是懒,特别是最近),特意写了一个一键更换pip源脚本,目前只在Centos上测试过,不过理论上Linux系统通用
使用
Centos/Debian/Ubuntu/RHEL通用(请先安装wget这种应该不用我说吧)
1
|
wget xiaofd.github.io/pip.sh && bash pip.sh
|
效果图: