为 Ubuntu/Anaconda/pip 添加国内下载源

背景

正在看 tensorflow-lite 压缩模型的部分,结果 tutorial 一上来就要卸旧版安装 tf-nightly (新版?反正小白下就vans了)
然而好不容易才编译好源码舍不得删。又建了一个 env 下载新版,速度慢的一比,挂了一上午还超时断了。
我寻思着好像之前同学帮我配过国内的镜像下载源,试了一下。

“一键使用TUNA”服务

按照清华开源软件镜像站上面说的步骤,进行如下操作就可以一键为Anaconda/PyPi/Ubuntu Linux等添加清华镜像:

wget https://tuna.moe/oh-my-tuna/oh-my-tuna.py
# For yourself
python oh-my-tuna.py
# ...or for everyone!
sudo python oh-my-tuna.py --global
# Get some help
python oh-my-tuna.py -h

但实测时,仅发现 /etc/apt/sources.list 文件修改了,但 pip 下载时并没有提速,暂未查明原因

手动修改 pip 下载源

Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹),内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

实测 pip 下载提速较为明显

手动修改 conda 下载源

运行以下命令:

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 --set show_channel_urls yes

实测提速明显

参考资料:

  1. https://tuna.moe/oh-my-tuna/
  2. https://www.cnblogs.com/microman/p/6107879.html
  3. https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
posted @ 2018-09-25 21:00  backtosouth  阅读(2288)  评论(0编辑  收藏  举报