conda and pip download too slow? add mirror

conda

When using Anaconda to install a third-party library, the default download website is abroad, so the download speed is very slow. You can add a domestic mirror source to increase the download speed.

1. Add Tsinghua mirror source
If the mirror source website fails, you can go to Tsinghua University Open Source Software Mirror Station | Tsinghua Open Source Mirror to obtain the URL.

# 添加清华镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
# 搜索时显示地址
conda config --set show_channel_urls yes

2. View the configuration of the conda channel

Display all channels of conda:

conda config --show channels

If the channel contains defaults, it needs to be deleted, so that the Tsinghua mirror source will be used by default when downloading:

conda config --remove channels defaults

3. Reset channel settings
If you want to delete all added mirror sources and reset the conda default source, you can use the following statement:

conda config --remove-key channels

pip

1. Add source

For example, add Tsinghua source https://pypi.tuna.tsinghua.edu.cn/simple:

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

If set multiple times, only the image source of the last set can be saved.

2. Delete the source

pip config unset global.index-url

3. Check which source is currently used

pip config list

Guess you like

Origin blog.csdn.net/qq_39763246/article/details/130720269