Accelerating pip and anaconda in China
Since the default addresses for pip and anaconda are very slow to access in China, adding domestic mirrors for acceleration is necessary.
Main Domestic Open Source Mirrors
Tsinghua University https://tuna.tsinghua.edu.cn
Alibaba Cloud http://mirrors.aliyun.com
Tencent Cloud https://mirrors.tencent.com
University of Science and Technology of China https://mirrors.ustc.edu.cn
University of Science and Technology of China http://mirrors.ustc.edu.cn
Tongji University http://mirrors.tongji.edu.cn
Adding and Modifying Conda Sources
According to actual speed tests in Shanghai, Tsinghua University’s mirror is the fastest (Tongji University should be faster in theory, but the actual speed is disappointing, 0-0), so we’ll use it as the default source.
Method 1: Add via command line
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
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 --set channel_priority strict
conda config --set show_channel_urls yes
Method 2: Modify configuration file
echo 'channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
channel_priority: strict
show_channel_urls: true
' > ~/.condarc
Adding and Modifying pip Sources
Like conda, directly use Tsinghua University’s mirror.
# Method 1: Use -i to specify address during installation, e.g. installing sklearn
## Temporary
pip install scikit-learn -i "https://pypi.tuna.tsinghua.edu.cn/simple"
## Permanent
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# Method 2: Modify configuration file
mkdir -p ~/.config/pip
echo '[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
' > ~/.config/pip/pip.conf
Summary
Accelerate installation of Python and R packages in China by modifying pip and conda sources.
- 原文作者:春江暮客
- 原文链接:https://www.bobobk.com/en/833.html
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。