pypa/pip · error · PipError
Could not determine editor to use.
Error message
Could not determine editor to use.
What it means
Raised by ConfigurationCommand._determine_editor when no editor can be found: --editor was not passed, and neither VISUAL nor EDITOR is set in the environment (configuration.py:281-289). 'pip config edit' needs an editor to launch, so it aborts.
Source
Thrown at src/pip/_internal/commands/configuration.py:289
# We successfully ran a modifying command. Need to save the
# configuration.
try:
self.configuration.save()
except Exception:
logger.exception(
"Unable to save configuration. Please report this as a bug."
)
raise PipError("Internal Error.")
def _determine_editor(self, options: Values) -> str:
if options.editor is not None:
return options.editor
elif "VISUAL" in os.environ:
return os.environ["VISUAL"]
elif "EDITOR" in os.environ:
return os.environ["EDITOR"]
else:
raise PipError("Could not determine editor to use.")
View on GitHub (pinned to d7d0d0a394)
Solutions
- Set EDITOR (or VISUAL): export EDITOR=nano (or vim, code --wait, etc.).
- Pass the editor inline: pip config edit --editor nano.
- Add the export to your shell profile (~/.bashrc, ~/.zshrc) for persistence.
Example fix
// before pip config edit // after pip config edit --editor nano
Defensive patterns
Strategy: validation
Validate before calling
import os
if not (editor_flag or os.environ.get("VISUAL") or os.environ.get("EDITOR")):
raise SystemExit("No editor: pass --editor or set VISUAL/EDITOR") Prevention
- Set EDITOR in your shell profile for persistence.
- In containers/CI, pass --editor explicitly or set the env var.
When it happens
Trigger: Running 'pip config edit' (with no --editor) in a shell where VISUAL and EDITOR are both unset, e.g. a minimal container, a fresh CI runner, or an SSH session without a profile.
Common situations: Containers/CI images that ship no EDITOR default; non-interactive shells; stripped-down embedded Python; a user who never set a default editor.
Related errors
- Editor Subprocess exited with exit code {e.returncode}
- Need exactly one file to operate upon (--user, --site, --glo
- Could not determine appropriate file.
- Can not open an editor for a file name containing " {fname}
- Got unexpected number of arguments, expected {n}. (example:
AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04).
Data as JSON: /data/errors/ec99aae741ee6566.json.
Report an issue: GitHub.