SiiWay ImgAPI
353 字
2 分钟
uv 换源 (设置镜像源)
TIP本文中的 Linux 路径在 Windows 上同理 (如
/home/wyf9/.config/uv/uv.toml->C:\Users\wyf9\.config\uv\uv.toml)
Mac: 没用过,自己改
TL; DR
Too long, didn’t read
# Linuxnano /home/$USER/.config/uv/uv.toml:: Windowsnotepad C:\Users\%USERNAME%\.config\uv\uv.tomlindex = [ {url = "https://pypi.tuna.tsinghua.edu.cn/simple/"}, {url = "https://mirrors.aliyun.com/pypi/simple/"}, {url = "https://mirror.sjtu.edu.cn/pypi/web/simple/"}, {url = "https://mirrors.ustc.edu.cn/pypi/web/simple/"}, {url = "https://mirrors.cernet.edu.cn/pypi/web/simple"}]TS; JR
Too short, just read
官方文档: https://docs.astral.sh/uv/concepts/configuration-files/
从以上文档中, 我们便可以知道:
- uv 的配置文件在
~/.config/uv/uv.toml - 可以在里面配置镜像源
如果你只想设置一个镜像源:
[[index]]url = "https://pypi.tuna.tsinghua.edu.cn/simple/"default = true如果想设置多个:
[[index]]url = "https://pypi.tuna.tsinghua.edu.cn/simple/"default = true
[[index]]url = "https://mirrors.cernet.edu.cn/pypi/web/simple"default = true也可以用这样的格式:
index = [ {url = "https://pypi.tuna.tsinghua.edu.cn/simple/"}, {url = "https://mirrors.aliyun.com/pypi/simple/"}, {url = "https://mirror.sjtu.edu.cn/pypi/web/simple/"}, {url = "https://mirrors.ustc.edu.cn/pypi/web/simple/"}, {url = "https://mirrors.cernet.edu.cn/pypi/web/simple"}]常用的镜像列表
TIP镜像描述 -> Grok
- 清华大学 (TUNA): https://pypi.tuna.tsinghua.edu.cn/simple/
国内最稳定、更新及时的镜像之一。
下载速度快,适合大规模使用。
- 中国科学技术大学 (USTC): https://mirrors.ustc.edu.cn/pypi/web/simple/
学术镜像,包完整度高。
- 上海交通大学 (SJTU): https://mirrors.sjtu.edu.cn/pypi/web/simple/
教育机构镜像,稳定可靠。
轻量级镜像,速度中等。
商业镜像,覆盖全面。
云服务提供商镜像,下载高效。
老牌镜像,适合备用。
- 北京外国语大学 (BFSU): https://mirrors.bfsu.edu.cn/pypi/web/simple/
教育镜像,更新较快。
pip 如何设置
临时:
pip install fastapi -i MIRROR-URL永久:
pip config set global.index-url MIRROR-URLTIP将上面的
MIRROR-URL替换为你的镜像地址