Python Package Index Mirror Sources

从国外的 Python 库安装 package 速度太慢(几十Kbps),将 PIP 源 (pypi) 换成国内镜像可以将下载速率可以提升到数 Mpbs。

pypi mirror, python package source

临时使用国内 PIP 源

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple package-name
# or
pip install package-name -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install tensorflow-gpu==2.1.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

添加信任选项:

sudo pip install -i http://pypi.douban.com/simple/ \
--trusted-host=pypi.douban.com/simple ipython

假设你想安装 pymysql, 使用豆瓣源安装方法:

pip install -i https://pypi.douban.com/simple/ pymysql  
  • channel 的参数名为 -i;

  • 参数 channel 与 packge-name 可以互换顺序

永久修改pip源

升级 pip

升级 pip 到最新的版本 (>=10.0.0) 后进行配置:

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

如果您到 pip 默认源的网络连接较差,临时使用镜像站来升级 pip:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U

pip 配置清华源

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

添加 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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

Reference

Anaconda中科大源关闭了,如何解决conda install命令下载速度慢的问题? - 机器学习是魔鬼的回答 - 知乎 https://www.zhihu.com/question/322862374/answer/1662070278