外观
包管理器配置:Python
| 包管理器 | 适用语言 | 主配置文件路径 | 官方首页 |
|---|---|---|---|
| pip | Python | ~/.config/pip/pip.conf | pypi.org |
| uv | Python | ~/.config/uv/uv.toml | docs.astral.sh |
pip
(1)使用pip config命令
配置国内代理:
shell
# 设置index-url
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
# 设置trusted-host
pip config set global.trusted-host mirrors.aliyun.com
# 设置timeout
pip config set global.timeout 60
# 查看所有配置
pip config list(2)编辑pip.conf文件
shell
vim ~/.config/pip/pip.confini
[global]
timeout = 60
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host=mirrors.aliyun.comtips1: 编辑
~/.config/pip/pip.conf文件与pip config命令等效
tips2: 也可以编辑
~/.pip/pip.conf文件修改配置,但它的优先级要小于~/.config/pip/pip.conf
uv
(1)编辑uv.toml文件
shell
mkdir ~/.config/uv
vim ~/.config/uv/uv.tomltoml
# 加速Python解释器下载 (uv python install)
python-install-mirror = "https://registry.npmmirror.com/-/binary/python-build-standalone/"
# 加速Python包下载 (uv add)
[[index]]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
default = true