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

一、修改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,如果是其他版本,可以在清华源的网站上找到其对应的原文件,放入即可。

1deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse 2deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse 3deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse 4deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse 5deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse 6deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse 7deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse 8deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse 9deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse 10deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

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

1sudo apt-get update 2sudo apt-get upgrade

另附阿里源:

1deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse 2deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse 3deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse 4deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse 5deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse 6deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse 7deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse 8deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse 9deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse 10deb-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”键,进入编辑模式,复制信息:

    1[global] 2index-url = https://pypi.tuna.tsinghua.edu.cn/simple 3trusted-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”保存离开。

点赞
收藏

评论区

加载中...

相关推荐

国内镜像大全

前言    由于许多软件以及依赖包需要从github或国外源下载,导致下载安装失败或下载速度慢是家常便饭的事,所以阿都从互联网上收集并统计了相关的镜像源,与大家分享。希望和大家一起共同丰富相关内容,阿都也会一直去维护,争取帮助到更多的同学。用法镜像中可以下载各种系统【centos、ubuntu】、软件【atom、gi

Centos配置国内yum源

网易(163)yum源是国内最好的yum源之一,无论是速度还是软件版本,都非常的不错,将yum源设置为163yum,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到。具体设置方法如下:1,进入yum源配置目录cd/etc/yum.repos.d2,备份系统自带的yum源mvCentOSBase.repoCentO

.pip的时候出现Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))…………

pip的幺蛾子:有时候在用pip安装python中的包的时候,会出先请求失败的现象,一开始还以为是自己的网不够好,后来才发现。。。。。。原因:pip的下载源存在国外和国内之分,一般来说国内的源下载会块很多,国外的源会有速度限制,从而造成请求失败从而不能安装你想要的模块.解决方法:几种国内常用的pip源阿里云:http://mirro

ubuntu 16.04 跑 docker

Ubuntu的软件源配置文件是 /etc/apt/sources.list换国内的,不然会疯。下面是清华大学滴:默认注释了源码镜像以提高aptupdate速度,如有需要可自行取消注释debhttps://mirrors.tuna.tsinghua.edu.cn/ubuntu/xenialmainrestric

CentOS 7 yum nginx MySQL PHP 简易环境搭建

用centos自带的yum源来安装nginx,mysql和php,超级方便,省去编译的麻烦,省去自己配置的麻烦,还能节省非常多的时间。我们先把yum源换成国内的阿里云镜像源(当然不换也可以),先备份一下原来的源镜像文件,以免出错后可以恢复:\root@192~\mv/etc/yum.repos.d/CentOSBase.repo/et

Python 修改pip源

接触python多半年光景了,多数时间都是在公司看看书,最近终于有空在家学学python,写点代码。可是涉及到python,就要说到python的模块了,python不管从代码风格还是涉及面上,都辣么辣么的惊艳。好吧,谈及下载python第三方模块,势必谈及pip,默认的pip源下载速度实在是不给力啊不给力。所以修改pip源吧。特别注意了