pypa/pip · error · ConfigurationError
No such key
Error message
No such key - {orig_key} What it means
Raised by Configuration.get_value() after merging all loaded configuration layers into a flat dict and failing to find the requested key. Before raising, it calls _disassemble_key to produce a better hint if the key lacks a dot. This surfaces when a user queries a config key that does not exist in any loaded layer (file or environment).
Solutions
- Verify the key exists with `pip config list` or `pip config debug`.
- Set the key first with `pip config set global.<name> <value>` if you intended it to exist.
- Check the spelling and section prefix against pip's documented options.
Example fix
# before pip config get global.index-url # not set yet # after pip config set global.index-url https://pypi.org/simple pip config get global.index-url
Defensive patterns
Strategy: validation
Validate before calling
from pip._internal.configuration import Configuration
def config_get_safe(cfg: Configuration, key: str, default=None):
try:
return cfg.get_value(key)
except Exception: # ConfigurationError
return default
Try / catch
from pip._internal.exceptions import ConfigurationError
try:
value = cfg.get_value(key)
except ConfigurationError:
value = None # key not set; use default
Prevention
- Use `pip config list`/`pip config debug` to confirm keys before querying.
- Remember pip does not store defaults — only explicitly-set values appear in config.
When it happens
Trigger: Running `pip config get global.nonexistent` or `pip config get some.typo` where the key is not present in any pip.conf or PIP_ environment variable.
Common situations: Querying an option before it has been set; misspelling a key; expecting a default value to appear in config (pip only stores explicitly-set values, not defaults).
Related errors
- Got invalid value for load_only - should be one of
- Key does not contain dot separated section and key. Perhaps…
- Needed a specific file to be modifying.
- An error occurred while writing to the configuration file
- Can not perform a '--user' install. User site-packages are…
AI-assisted analysis of pypa/pip@f399c37189 (2026-08-08).
Data as JSON: /api/errors/bb103c0abff14508.
Report an issue: GitHub.
Appendix: source
Thrown at src/pip/_internal/configuration.py:157
"""Returns key-value pairs like dict.items() representing the loaded
configuration
"""
return self._dictionary.items()
def get_value(self, key: str) -> Any:
"""Get a value from the configuration."""
orig_key = key
key = _normalize_name(key)
try:
clean_config: dict[str, Any] = {}
for file_values in self._dictionary.values():
clean_config.update(file_values)
return clean_config[key]
except KeyError:
# disassembling triggers a more useful error message than simply
# "No such key" in the case that the key isn't in the form command.option
_disassemble_key(key)
raise ConfigurationError(f"No such key - {orig_key}")
def set_value(self, key: str, value: Any) -> None:
"""Modify a value in the configuration."""
key = _normalize_name(key)
self._ensure_have_load_only()
assert self.load_only
fname, parser = self._get_parser_to_modify()
if parser is not None:
section, name = _disassemble_key(key)
# Modify the parser and the configuration
if not parser.has_section(section):
parser.add_section(section)
parser.set(section, name, value)
self._config[self.load_only].setdefault(fname, {})View on GitHub (pinned to f399c37189)