ubuntu18.04里更新系统源和pip源

Wesley13
• 阅读 718

一、修改ubuntu系统源

我的ubuntu系统是在清华的开源网站上下的,所以我还以为他应该就帮我弄好源了,可是没想到下载的还是非常慢,看到下载的时候网址前还有个us,就知道不是国内源了。所以这里我们来换系统源。(ps:我上次用的阿里云服务器好像倒是直接就是阿里的源了,速度还可以。)

国内有很多Ubuntu的镜像源,包括阿里的、网易的,还有很多教育网的源,比如:清华源、中科大源。 
我们这里以清华源为例讲解如何修改Ubuntu 18.04里面默认的源。

1、输入命令修改sources.list文件,当然需要超级权限,所以要加sudo;

sudo gedit /etc/apt/sources.list

(可选)备份原文件:

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

2、在文件最前面添加以下条目(操作前请做好相应备份):

这里需要特别注意ubuntu的版本,我的是18.04,所以是bionic,如果是其他版本,可以在清华源的网站上找到其对应的原文件,放入即可。

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

3、修改完成后,保存文件,警告什么的都不理,然后运行下面的命令。

sudo apt-get update
sudo apt-get upgrade

另附阿里源:

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

二、修改python的pip的源

  1. 根目录创建.pip文件:mkdir ~/.pip

  2. 创建文件pip.conf:vim .pip/pip.conf

  3. 点击“i”键,进入编辑模式,复制信息:

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

    这个更换的是清华的源,清华的源5分钟同步官网一次,建议使用。另附上其他源:
    清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
    阿里云 http://mirrors.aliyun.com/pypi/simple/
    中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
    豆瓣(douban) http://pypi.douban.com/simple/
    中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

  4. 点击:“ESC”切换到命令行模式,输入“:wq”保存离开。

点赞
收藏
评论区
推荐文章
菜鸟阿都 菜鸟阿都
2年前
国内镜像大全
前言    由于许多软件以及依赖包需要从github或国外源下载,导致下载安装失败或下载速度慢是家常便饭的事,所以阿都从互联网上收集并统计了相关的镜像源,与大家分享。希望和大家一起共同丰富相关内容,阿都也会一直去维护,争取帮助到更多的同学。用法镜像中可以下载各种系统【centos、ubuntu】、软件【atom、gi
Wesley13 Wesley13
2年前
Centos配置国内yum源
网易(163)yum源是国内最好的yum源之一,无论是速度还是软件版本,都非常的不错,将yum源设置为163yum,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到。具体设置方法如下:1,进入yum源配置目录cd/etc/yum.repos.d2,备份系统自带的yum源mvCentOSBase.repoCentO
Wesley13 Wesley13
2年前
.pip的时候出现Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))…………
pip的幺蛾子:有时候在用pip安装python中的包的时候,会出先请求失败的现象,一开始还以为是自己的网不够好,后来才发现。。。。。。原因:pip的下载源存在国外和国内之分,一般来说国内的源下载会块很多,国外的源会有速度限制,从而造成请求失败从而不能安装你想要的模块.解决方法:几种国内常用的pip源阿里云:http://mirro
Wesley13 Wesley13
2年前
ubuntu 16.04 跑 docker
Ubuntu的软件源配置文件是 /etc/apt/sources.list换国内的,不然会疯。下面是清华大学滴:默认注释了源码镜像以提高aptupdate速度,如有需要可自行取消注释debhttps://mirrors.tuna.tsinghua.edu.cn/ubuntu/xenialmainrestric
Stella981 Stella981
2年前
CentOS 7 yum nginx MySQL PHP 简易环境搭建
用centos自带的yum源来安装nginx,mysql和php,超级方便,省去编译的麻烦,省去自己配置的麻烦,还能节省非常多的时间。我们先把yum源换成国内的阿里云镜像源(当然不换也可以),先备份一下原来的源镜像文件,以免出错后可以恢复:\root@192~\mv/etc/yum.repos.d/CentOSBase.repo/et
Stella981 Stella981
2年前
Python 修改pip源
接触python多半年光景了,多数时间都是在公司看看书,最近终于有空在家学学python,写点代码。可是涉及到python,就要说到python的模块了,python不管从代码风格还是涉及面上,都辣么辣么的惊艳。好吧,谈及下载python第三方模块,势必谈及pip,默认的pip源下载速度实在是不给力啊不给力。所以修改pip源吧。特别注意了
Stella981 Stella981
2年前
Linux安装软件、python开发环境
软件安装与卸载更新Ubuntu软件下载地址1\.寻找国内镜像源所谓的镜像源:可以理解为提供下载软件的地方,比如Android手机上可以下载软件的91手机助手;iOS手机上可以下载软件的AppStore2\.备份Ubuntu默认的源地址sudocp/etc/apt
Wesley13 Wesley13
2年前
Ubuntu 国内安装 kubernetes
由于墙的原因,国内要安装kubernetes非常的麻烦,因此只要解决这个问题,就可以顺利安装kubernetes的三个官法工具kubelet、kubeadm、kubectl。安装环境:OS:Ubuntu18.04.11.添加相应的源我在这里使用阿里源,命令如下:sudovim/
Stella981 Stella981
2年前
CentOS服务器安装笔记(二)
6系统初始化6.1更新软件源(可选,本次安装未使用)可以更新自带的yum源为国内的搜狐和网易源,但实际测试自带的源速度很快(400600K/s),因此本步骤可选。安装步骤1、下载repo文件下载地址:http://mirrors.163.com/.help/CentOS6Base163.repo(http
芝士年糕 芝士年糕
1年前
ubuntu全版本通用换源教程
我使用3A服务器安装Ubuntu系统,但是安装的时候需要转到国内的每个版本的源都是不同的,如果源的版本不同就会出现很多的错误,比如gcc缺少依赖项等首先打开终端输入languagelsb_releasea!imag