当前位置: 首页 > article >正文

macos查询pip默认镜像地址

在 macOS 系统中,查询 pip 的默认镜像地址可以通过以下几种方法:

方法 1:直接通过 pip config list 命令查询

运行以下命令查看当前 pip 的配置(包括镜像地址):

pip config list

如果输出中包含 global.index-url 或 install.trusted-host,则显示的是当前配置的镜像地址。例如:

global.index-url=https://pypi.tuna.tsinghua.edu.cn/simple
install.trusted-host=pypi.tuna.tsinghua.edu.cn

如果无输出,说明未显式配置镜像,默认使用 PyPI 官方源:

https://pypi.org/simple。

方法 2:检查 pip 配置文件

pip 的配置文件优先级为:

  1. 用户级配置~/.pip/pip.conf 或 ~/.config/pip/pip.conf

  2. 全局配置/etc/pip.conf

查看配置文件内容:

# 查看用户级配置
cat ~/.pip/pip.conf 2>/dev/null || cat ~/.config/pip/pip.conf 2>/dev/null

# 查看全局配置
cat /etc/pip.conf 2>/dev/null

若配置了镜像,会显示类似以下内容:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple
trusted-host = mirrors.aliyun.com

方法 3:通过 Python 代码查询(适用于编程场景)

from pip._internal.commands.configuration import get_pip_config
config = get_pip_config()
index_url = config.get_value("global.index-url")
print(f"当前镜像地址: {index_url or '默认 PyPI (https://pypi.org/simple)'}")

默认镜像地址

如果未手动配置镜像,pip 默认使用 PyPI 官方源

https://pypi.org/simple。

常见国内镜像地址示例

镜像名称地址
清华大学https://pypi.tuna.tsinghua.edu.cn/simple
阿里云https://mirrors.aliyun.com/pypi/simple
华为云https://repo.huaweicloud.com/repository/pypi/simple
豆瓣https://pypi.doubanio.com/simple

总结

  • 使用 pip config list 直接查看生效的配置。

  • 检查 ~/.pip/pip.conf 或 /etc/pip.conf 文件。

  • 若未配置镜像,默认地址为 PyPI 官方源。


http://www.kler.cn/a/578635.html

相关文章:

  • Flask 框架简介
  • 软考初级程序员知识点汇总
  • 建筑兔零基础自学记录42|cityengine2019导入sketchup/SU 2
  • 在Rocky Linux上安装Redis(DNF和源码安装)
  • 每日一练之合并两个有序链表
  • 冒泡排序的算法实现
  • 基于PySide6的CATIA零件自动化着色工具开发实践
  • CGI程序刷新共享内存视频流到HTTP
  • redis有哪几种持久化方式
  • 【求Fibonacci(斐波那契)数列】
  • pycharm找不到conda可执行文件
  • k8s的配置文件说明
  • 二进制,十六进制,十进制
  • OpenFeign:优雅实现微服务远程调用
  • 【Linux网络】NAT技术、DNS系统、五种IO模型
  • UE5 AssetManager类使用详解
  • 基于大模型之力,重构 AI 数字化销售版图
  • WOA-Transformer鲸鱼算法优化编码器时间序列预测(Matlab实现)
  • 单细胞分析(22)——高效使用 Cell Ranger:安装、参数解析及 Linux 后台运行指南
  • ClassUtil:Hutool库中反射操作的高效利器