ubuntu20如何换源
时间: 2023-10-20 14:34:04 浏览: 119
在Ubuntu 20中,你可以通过以下步骤来更换源:
1. 备份并替换sources.list文件:
- 首先备份原有的源文件:
```
cp -a /etc/apt/sources.list /etc/apt/sources.list.bak
```
- 使用wget命令将源更换为腾讯源:
```
wget -O /etc/apt/sources.list http://mirrors.cloud.tencent.com/repo/ubuntu20_sources.list
```
- 刷新源列表以使更改生效:
```
apt-get clean all && apt-get update
```
2. 更换pip源:
- 在用户路径下创建.pip/pip.conf文件:
```
mkdir ~/.pip
sudo gedit ~/.pip/pip.conf
```
- 将以下内容添加到pip.conf文件中,并保存:
```
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
```
3. 更换conda源:
- 将以下信息复制粘贴到.condarc文件中,并保存:
```
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
```
通过以上步骤,你可以成功更换Ubuntu 20的源为腾讯源,pip源和conda源为清华源。请确保按照步骤操作,并且保存修改后重启相应的软件或服务,以确保更改生效。<span class="em">1</span><span class="em">2</span><span class="em">3</span><span class="em">4</span>
阅读全文