ubuntu 更换系统源和pip源

时间:2021-02-19 14:57:51

1 . 备份

cd /etc/apt
sudo cp sources-list sources-list.bak

2 . 编辑
这里用了阿里云的源

sudo vi sources-list

将文件内容替换成以下:

deb http://mirrors.aliyun.com/ubuntu/ vivid main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ vivid-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ vivid-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ vivid-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ vivid-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ vivid main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ vivid-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ vivid-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ vivid-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ vivid-backports main restricted universe multiverse

3 . 更新

sudo apt-get updata

更新pip源
1 . 可以直接在pip时加入参数
比如:

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

2 . 修改默认设置
在根目录下创建.pip目录,创建pip.conf,并写入

[global]

index-url = http://pypi.douban.com/simple

[install]

trusted-host=pypi.douban.com