工具部署
一键安装
1
| curl -LsSf https://astral.sh/uv/install.sh | sh
|
1
| powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
手工安装
- 打开页面:https://github.com/astral-sh/uv/releases/
- 下载对应版本
镜像源修改
全局修改
Windows:%APPDATA%\uv\uv.toml
Linux/macOS:~/.config/uv/uv.toml
腾讯源
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| cat <<EOF > ~/.config/uv/uv.toml
[[index]]
url = "https://mirrors.cloud.tencent.com/pypi/simple"
name = "tencent"
default = true
[[index]]
url = "https://mirrors.aliyun.com/pypi/simple"
name = "aliyun"
default = false
[[index]]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
name = "tsinghua"
default = false
EOF
|
项目级别的源设定
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| # 默认使用腾讯云源,加速依赖安装
[[tool.uv.index]]
url = "https://mirrors.cloud.tencent.com/pypi/simple"
name = "tencent"
default = true
# 备用:阿里云源
[[tool.uv.index]]
url = "https://mirrors.aliyun.com/pypi/simple"
name = "aliyun"
default = false
# 备用:清华源
[[tool.uv.index]]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
name = "tsinghua"
default = false
# 官方 PyPI 源
[[tool.uv.index]]
url = "https://pypi.org/simple"
name = "pypi"
default = false
|
查看配置
1
| cat ~/.config/uv/uv.toml
|
通过命令行临时指定
在运行 uv 命令时,可以直接指定镜像源:
1
| uv add --default-index https://mirrors.cloud.tencent.com/pypi/simple <包名>
|
| 平台 | 配置文件路径 | 一键创建目录 |
|---|
| Windows | %APPDATA%\\uv\\uv.toml | mkdir %APPDATA%\\uv |
| Linux / macOS | ~/.config/uv/uv.toml | mkdir -p ~/.config/uv |