1.更改conda源
1.根目录下输入如下代码,生成配置文件.condarc:
conda config --set show_channel_urls yes
2.配置文件路径 ~/.condarc,使用vim打开它,并添加我们的源
vim ~/.condarc
比如在.condarc文件中添加conda源
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
ssl_verify: true
3.保存并退出.condarc文件
:wq
4.刷新.condarc文件,或者重启服务器
source用法参考:Linux中source命令的使用方式_如何在终端里用source-CSDN博客
source ~/.condarc
注意source是刷新当前的环境,而不是保存
2.更改pip源
1.在根目录下创建.pip文件夹
mkdir ~/.pip
2.在创建好的.pip文件夹下创建pip源配置文件
touch ~/.pip/pip.conf #生成pip.conf 文件
3.使用vim打开pip.conf配置文件
vim ~/.pip/pip.conf
比如在pip.conf文件中添加pip源
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
4.保存退出pip.conf文件
:wq
5.刷新pip.conf文件,或者重启服务器
source ~/.pip/pip.conf