Skip to content

/config/pip/pip-conf-index-url

pip.conf index-url: use a private or mirror package index

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · pip 26.2.1 fromupdated
tool
pip
file
pip.conf (pip.ini on Windows)
key
global.index-url
type
URL of a PEP 503 simple index
default
https://pypi.org/simple

index-url sets the package index pip installs from instead of PyPI. Put it in the [global] section of pip.conf (pip.ini on Windows), set the PIP_INDEX_URL environment variable, or pass --index-url on the command line. pip config list shows what pip actually reads.

pip.conf
[global]
index-url = https://pypi.example.com/simple

Set it and check it

bash
cat > pip.conf <<'EOF'
[global]
index-url = https://pypi.example.com/simple
EOF
export PIP_CONFIG_FILE="$PWD/pip.conf"
pip config --disable-pip-version-check list
echo "--- with PIP_INDEX_URL set"
PIP_INDEX_URL=https://mirror.example.org/simple pip config --disable-pip-version-check list

Output

:env:.config-file='/tmp/work/pip.conf'
global.index-url='https://pypi.example.com/simple'
--- with PIP_INDEX_URL set
:env:.config-file='/tmp/work/pip.conf'
:env:.index-url='https://mirror.example.org/simple'
global.index-url='https://pypi.example.com/simple'

PIP_CONFIG_FILE points pip at one specific file, which is handy in CI and containers. Values that come from environment variables are listed with the :env: prefix, and PIP_INDEX_URL wins over the file. pip config set global.index-url URL writes the user configuration file instead and prints its path.

Where pip looks

ScopeLinuxmacOSWindows
Global/etc/pip.conf (and XDG config dirs)/Library/Application Support/pip/pip.confC:\ProgramData\pip\pip.ini
User~/.config/pip/pip.conf~/Library/Application Support/pip/pip.conf%APPDATA%\pip\pip.ini
User (legacy)~/.pip/pip.conf~/.pip/pip.conf%HOME%\pip\pip.ini
Site (inside a venv)$VIRTUAL_ENV/pip.conf$VIRTUAL_ENV/pip.conf%VIRTUAL_ENV%\pip.ini

Files are read from global to site, and later ones override earlier ones. Environment variables (PIP_<OPTION>) override all files, and command-line options override everything. pip config debug prints every file pip considered and whether it exists.

index-url vs extra-index-url

pip.conf
[global]
index-url = https://pypi.example.com/simple
extra-index-url = https://pypi.org/simple

extra-index-url adds indexes; pip then picks the best matching version across all of them.

Credentials

Do not put passwords in pip.conf. Use a keyring backend, a .netrc file, or let CI inject the full URL through PIP_INDEX_URL as a secret.

Sources