Skip to content

包管理器配置:Python ​

包管理器适用语言主配置文件路径官方首页
pipPython~/.config/pip/pip.confpypi.org
uvPython~/.config/uv/uv.tomldocs.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.conf
ini
[global]
timeout = 60
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host=mirrors.aliyun.com

tips1: 编辑~/.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.toml
toml
# 加速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