Appearance
Python 镜像源配置
记录 pip 和 uv 使用国内镜像源的常用配置方法。
使用 pip 镜像
也可以写入全局配置:
bash
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn临时使用 uv 镜像
如果某个安装脚本内部会调用 uv,可以先导出环境变量再执行:
bash
export UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
export UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
export UV_HTTP_TIMEOUT=120持久化配置 uv 镜像
如果希望后续所有 uv 命令默认使用镜像,可以写入配置文件:
bash
mkdir -p ~/.config/uv && vi ~/.config/uv/uv.tomltext
index-url = "https://pypi.tuna.tsinghua.edu.cn/simple"