Python 设置国内镜像

从Python官网下载、安装python之后(不建议使用brew安装python3)

MacOS :打开/User/xxx/.config/pip/pip.conf
Windows:打开%APPDATA%\pip\pip.ini

写入如下内容:

# 对所有的pip命令有效
[global]

# 设置超时
timeout         = 30

# 设置主镜像源
index-url       = https://mirrors.aliyun.com/pypi/simple/

# 设置备用镜像源(防止主源抽风)
extra-index-url = https://pypi.tuna.tsinghua.edu.cn/simple
                  https://pypi.org/simple

# 禁止 pip 自动更新
upgrade         = false

# 禁止 pip 版本检查(加快安装)
disable-pip-version-check = true

# 启用进度条(默认启用,设置为 off 可关闭)
progress-bar    = on

# 仅对pip install有效
[install]

# 配置信任的主机(如果证书有问题可避免出错)
trusted-host    = mirrors.aliyun.com
                  pypi.tuna.tsinghua.edu.cn
                  pypi.org

posted @ 2025-05-12 13:27  江南烟雨梦  阅读(62)  评论(0)    收藏  举报