如何给python的包管理工具uv换源?
方法一:设置环境变量
export UV_DEFAULT_INDEX="https://mirrors.aliyun.com/pypi/simple"
方法二:新建或修改全局配置文件(Linux和MacOS一般是~/.config/uv/uv.toml,Windows一般是%APPDATA%/uv/uv.toml,路径不存在的话直接手动创建即可)
index-url="https://mirrors.cloud.tencent.com/pypi/simple/"
注:如果域名是http而非https,需要加上allow-insecure-host=["xxx.com"]
更多配置见uv文档:https://docs.astral.sh/uv/configuration/files/
方法三:修改当前项目的pyproject.toml
[tool.uv]
index-url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
参考:https://github.com/astral-sh/uv/issues/6925
附:方法二脚本版,一行命令搞定
curl https://gh-proxy.com/raw.githubusercontent.com/waketzheng/carstino/main/pip_conf.py -o pip_conf.py && python pip_conf.py aliyun --uv