换源

换源

apt 换源

sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
sudo bash -c "cat << EOF > /etc/apt/sources.list && apt update 
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
EOF"

pip换源

修改或创建 ~/.pip/pip.conf :

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

或者输入命令

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

其他常用源:

  1. 中科大源(https://pypi.mirrors.ustc.edu.cn/simple/)

    中科大源是中国科学技术大学提供的镜像源,速度快且稳定。

  2. 豆瓣源(https://pypi.douban.com/simple/)

    豆瓣源是豆瓣提供的镜像源,速度也比较快。

  3. 清华源(https://pypi.tuna.tsinghua.edu.cn/simple/)

    清华源是清华大学提供的镜像源,速度较快。

  4. 阿里云源(http://mirrors.aliyun.com/pypi/simple/)

    阿里云源是阿里云提供的镜像源,速度也比较快。

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/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
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
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

对于WSL,命令行输入

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda

docker换源

#使用阿里云镜像加速器
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://hub-mirror.c.163.com",
"https://ghcr.io",
"https://mirror.baidubce.com"
]
}
EOF
systemctl daemon-reload
systemctl restart docker
------ 本文结束 🎉🎉 谢谢观看 ------
0%