pip 镜像源及其设置方法

🌐 常用国内镜像源清单(推荐使用)

镜像名称URL稳定性更新频率
清华镜像站https://pypi.tuna.tsinghua.edu.cn/simple⭐⭐⭐⭐⭐非常高
阿里云镜像https://mirrors.aliyun.com/pypi/simple⭐⭐⭐⭐⭐
中科大镜像https://pypi.mirrors.ustc.edu.cn/simple⭐⭐⭐⭐
豆瓣镜像https://pypi.doubanio.com/simple⭐⭐⭐⭐较高
华为云镜像https://repo.huaweicloud.com/repository/pypi/simple⭐⭐⭐⭐
腾讯云镜像https://mirrors.cloud.tencent.com/pypi/simple⭐⭐⭐中等

推荐首选​:清华镜像站或阿里云镜像,更新速度快且稳定性好

快速使用方法

pip install <包名称> -i <镜像URL> 


🛠 设置默认镜像源方法

方法一:临时使用镜像源(单次安装)

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple package-name

方法二:命令行永久配置(用户级)

Windows (CMD/PowerShell):
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn
macOS/Linux:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn

🔍 验证配置是否生效

# 查看当前配置
pip config list

# 安装测试包验证速度
pip install -U pip --verbose

不同系统下的最佳实践

  • Windows: 建议使用配置文件方式,避免权限问题
  • macOS/Linux: 可结合环境变量和全局配置

🔁 恢复默认镜像源

# 方法一:删除配置文件
rm ~/.pip/pip.conf  # macOS/Linux
del %APPDATA%\pip\pip.ini  # Windows

# 方法二:命令行重置
pip config unset global.index-url
pip config unset global.trusted-host

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值