/config/pip/pip-conf-index-url
pip.conf index-url: use a private or mirror package index
- 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.
[global]
index-url = https://pypi.example.com/simpleSet it and check it
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 listOutput
: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
| Scope | Linux | macOS | Windows |
|---|---|---|---|
| Global | /etc/pip.conf (and XDG config dirs) | /Library/Application Support/pip/pip.conf | C:\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
[global]
index-url = https://pypi.example.com/simple
extra-index-url = https://pypi.org/simpleextra-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.