国内python pip加速下载

Linux

# 持久加速
mkdir -p ~/.pip
# 清华 source
cat << EOF > ~/.pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
EOF
# 豆瓣源 source 
cat << EOF > ~/.pip/pip.conf
[global]
index-url = https://pypi.douban.com/simple
[install]
trusted-host = pypi.douban.com
EOF
#临时加速
pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com/pypi/simple/ packagename

Windows

在 C:\Users\user name \AppData\Roaming\pip 目录创建 pip.ini 文件
粘贴以下内容
[global]
index-url = https://pypi.mirrors.ustc.edu.cn/simple/

ref

man pages of pip &&
https://pip.pypa.io/en/stable/topics/configuration/?highlight=pip.conf
这些才是一手知识 😃

posted @ 2023-02-23 10:43  wangshaodong  阅读(57)  评论(0编辑  收藏  举报