6

pip及anaconda国内加速

 2 years ago
source link: https://www.bobobk.com/833.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

pip及anaconda国内加速

2021年12月6日

| 技术

由于pip及anaconda的默认地址在国内访问速度感人,添加国内源进行加速十分必要

国内主要开源加速地址

清华大学 https://tuna.tsinghua.edu.cn

阿里云 http://mirrors.aliyun.com

腾讯云 https://mirrors.tencent.com

中国科技大学 https://mirrors.ustc.edu.cn

中国科学技术大学 http://mirrors.ustc.edu.cn

同济大学 http://mirrors.tongji.edu.cn

添加及修改conda源

根据在上海的实际速度看,清华大学的速度最快(同济大学本应该速度最快,然而实际速度感人,0-0),因此将其作为默认源。

第一种方法,通过命令添加

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

第二种方法,修改配置文件

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

添加及修改pip源

跟conda一样,直接选用清华大学源

# 第一种,安装时-i指定地址,比如安装sklearn
## 临时
pip install scikit-learn -i "https://pypi.tuna.tsinghua.edu.cn/simple"
## 永久
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

# 第二种,修改配置文件
mkdir -p ~/.config/pip
echo '[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
' > ~/.config/pip/pip.conf

通过修改pip及conda源进行国内安装python包及R包加速。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK