You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查看pip install的默认索引地址及镜像优先级?

How to Check Pip's Index URLs and Their Priority

Great question! Let's walk through exactly how to see which indexes pip uses during installation, how to verify their priority, and whether the verbose flag helps (spoiler: it's super useful).

1. View Configured Index URLs Directly

The simplest way to see all your current pip index settings (including their sources) is to use the pip config list command. This will output all active configurations, including index-related entries:

pip config list

You'll see lines like:

global.index-url=https://pypi.org/simple/
user.extra-index-url=https://mirrors.aliyun.com/pypi/simple/

This tells you the default primary index (index-url) and any additional fallback indexes (extra-index-url) pip is configured to use.

2. Use Verbose Mode to See Real-Time Index Usage

Absolutely, adding the -v (or --verbose) flag to your pip install command is one of the most effective ways to see exactly which indexes pip accesses, in the order it checks them.

Run your install command with verbose output:

pip install <package-name> -v

Look for the line near the start that begins with Looking in indexes: — this lists all the indexes pip will check, in the order of their priority. For example:

Looking in indexes: https://pypi.org/simple/, https://mirrors.aliyun.com/pypi/simple/

This means pip will first search the official PyPI index, then fall back to the Aliyun mirror if the package isn't found there.

As the command runs, you'll also get detailed logs of which URLs pip actually fetches from, like:

Fetching https://pypi.org/simple/requests/
Downloading https://pypi.org/packages/.../requests-2.31.0-py3-none-any.whl (62 kB)

This confirms exactly which index the package was retrieved from.

3. Understanding Index Priority Rules

To clarify how pip decides which index to use first:

  • Command-line arguments override everything: If you specify --index-url or --extra-index-url directly in your pip install command, these will take precedence over any config file settings.
  • User-level config beats global config: Settings in your user-specific config (like ~/.pip/pip.conf or ~/.config/pip/pip.conf) override system-wide global configs (like /etc/pip.conf).
  • index-url comes before extra-index-url: The main index-url is always checked first; any extra-index-url entries are only used if the package isn't found in the main index. If you have multiple extra-index-url entries, they're checked in the order they're listed in your config.

内容的提问来源于stack exchange,提问作者Andrea Bergonzo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:43:31