ubuntu 更换系统软件源 和 pip源

 一、 更换系统软件源

1、备份:

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

step 2: 获取 Ubuntu 代号
Ubuntu 每个发行版本都有自己的代号,我们要通过我们电脑上 Ubuntu 的代号去找对应的源,Ctrl+Alt+T 打开终端,执行以下命令:

lsb_release -a

然后会得到我们自己的 Ubuntu 的版本信息 ,最后一栏 codename 后面的就是我们自己的 Ubuntu 的代号。比如我安装的是 Ubuntu 18.04.1,查出来的代号就是 bionic.
 

2、修改:

sudo gedit /etc/apt/sources.list 
# 阿里云源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse


# 清华大学源
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu lunar universe
#deb http://archive.ubuntu.com/ubuntu lunar multiverse
#deb http://archive.ubuntu.com/ubuntu lunar main restricted

#deb http://archive.ubuntu.com/ubuntu lunar-updates universe
#deb http://archive.ubuntu.com/ubuntu lunar-updates multiverse
#deb http://archive.ubuntu.com/ubuntu lunar-updates main restricted

#deb http://archive.ubuntu.com/ubuntu lunar-security main restricted
#deb http://archive.ubuntu.com/ubuntu lunar-security universe
#deb http://archive.ubuntu.com/ubuntu lunar-security multiverse

#deb http://archive.ubuntu.com/ubuntu lunar-backports main restricted universe multiverse



# 清华大学源
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar main restricted

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-security multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-security main restricted

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-updates main restricted

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-backports main restricted universe multiverse

3、生效:

sudo apt-get update
sudo apt-get upgrade

参考
 

(71条消息) Ubuntu更换软件源_寥廓长空的博客-CSDN博客_ubuntu改源
 

二、ubuntu更改pip源

1、家目录~下创建.pip文件夹

mkdir ~/.pip 

2、创建pip.conf文件

sudo gedit ~/.pip/pip.conf

3、将以下内容复制进pip.conf中

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

4、完成。

补充:国内可用的pip源

阿里云 [http://mirrors.aliyun.com/pypi/simple/]
 
中国科技大学 [https://pypi.mirrors.ustc.edu.cn/simple/]
 
豆瓣(douban) [http://pypi.douban.com/simple/]
 
清华大学 [https://pypi.tuna.tsinghua.edu.cn/simple/]
 
中国科学技术大学 [http://pypi.mirrors.ustc.edu.cn/simple/]
 
华中理工大学:[http://pypi.hustunique.com/]
 
山东理工大学:[http://pypi.sdutlinux.org/]

三 、windows下更改pip源

1、创建文件夹

        win+R 打开用户目录%HOMEPATH%,在此目录下创建 pip 文件夹,在 pip 目录下创建 pip.ini 文件

2、拷贝进以下内容

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

3、参考

PIP 更换国内安装源_佛系程序员-CSDN博客_pip换源

  • 9
    点赞
  • 67
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值