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

背景

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

“一键使用TUNA”服务

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

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 下载时并无提速,暂未查明缘由url

手动修改 pip 下载源

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

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

实测 pip 下载提速较为明显htm

手动修改 conda 下载源

运行如下命令:blog

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

实测提速明显ip

参考资料:get

  1. https://tuna.moe/oh-my-tuna/
  2. http://www.javashuo.com/article/p-hwvocbpb-hh.html
  3. https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
相关文章
相关标签/搜索