Python uv 配置 extra url 镜像源
Python 镜像 About 758 wordspyproject.toml 配置
# pyproject.toml
# 1) 主源:清华 simple(作为 default,替代官方 PyPI)
[[tool.uv.index]]
name = "tsinghua"
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
default = true
# 2) 专用源:例如 PyTorch wheels(设为 explicit,防止其它包误用)
[[tool.uv.index]]
name = "pytorch-cn"
url = "https://mirror.sjtu.edu.cn/pytorch-wheels/cu121"
explicit = true
# 3) 把指定包钉到专用源
[tool.uv.sources]
torch = { index = "pytorch-cn" }
torchvision = { index = "pytorch-cn" }
torchaudio = { index = "pytorch-cn" }
全局环境变量设置
设置UV_EXTRA_INDEX_URL环境变量
macOS & Linux
export UV_EXTRA_INDEX_URL=https://mirror.sjtu.edu.cn/pytorch-wheels/cu121
Windows
$env:UV_EXTRA_INDEX_URL="https://mirror.sjtu.edu.cn/pytorch-wheels/cu121"
参考文档
https://docs.astral.sh/uv/reference/environment/#uv_extra_index_url
Views: 7 · Posted: 2026-06-12
———         Thanks for Reading         ———
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...