ubuntu更换apt源、pip源和conda源

ubuntu更换apt源、pip源和conda源

​ 在配置深度学习环境,下载安装包时,主要会使用apt源、pip源和conda源这三个进行包的下载。

一、更换apt源

​ 1.1、存放apt源的配置文件路径为/etc/apt/source.list,首先要对这个配置文件进行备份,备份命令如下。

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

​ 如果需要恢复原来的配置文件,只需要用备份的配置文件覆盖原来的配置文件即可,命令如下。

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

​ 1.2、使用gedit打开source.list文件,命令如下。

sudo gedit /etc/apt/sources.list

​ 打开界面如下,删除其中的内容,将阿里云镜像源粘贴在其中,点击保存。
ubuntu更换apt源、pip源和conda源_第1张图片
​ 不同版本的ubuntu系统,所粘贴的镜像源内容有所不同。

ubuntu16.04:

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

ubuntu18.04:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src 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-backports main restricted universe multiverse

ubuntu20.04:

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-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed 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

​ 1.3、最后更软件源,完成配置apt源。

sudo apt-get update

二、更换pip源

​ 豆瓣的pip源较快,建议使用。

​ 2.1、在用户路径下创建.pip/pip.conf文件,因为执行pip命令时,会先运行~/.pip/pip.conf文件,命令如下。

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

​ 将下面的命令添加到pip.conf文件中,点击保存,即可。

[global]
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com

​ 界面如下:
ubuntu更换apt源、pip源和conda源_第2张图片
三、更换conda清华源

​ conda命令运行时,会先运行~/.condarc配置文件。

​ 3.1、使用gedit打开.condarc。

sudo gedit ~/.condarc

​ 3.2、进入链接https://mirror.tuna.tsinghua.edu.cn/help/anaconda/,将下面图片中的信息,全部复制粘贴到.condarc中,点击保存,成功更换为conda清华源。
ubuntu更换apt源、pip源和conda源_第3张图片

你可能感兴趣的:(深度学习环境配置,ubuntu,python,linux,anaconda,docker)