Ubuntu18.04更新源(apt-get、pip)

apt-get阿里源

备份一下原来的:

sudo cp /etc/apt/sources.list /etc/apt/sources_bak.list

修改源文件:

sudo gedit /etc/apt/sources.list

改成下面的内容(不确定是否适用于除18以外版本)

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

改完后更新:

sudo apt-get update

pip3清华源

Ubuntu18.04自带了python3.6,但是pip3依旧是需要自行下载的(注意是pip3)
所以先下载一个pip3

sudo apt-get install python3-pip

pip清华源官方网址在这里:https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
如果只是想临时用一下,直接用命令即可:

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

如果想永久改成这个源,执行以下操作:

mkdir ~/.pip
gedit ~/.pip/pip.conf

在创建的文本中输入如下:

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

你可能感兴趣的:(系统,ubuntu)