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

  1. Set EDITOR (or VISUAL): export EDITOR=nano (or vim, code --wait, etc.).
  2. Pass the editor inline: pip config edit --editor nano.
  3. 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

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


AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04). Data as JSON: /data/errors/ec99aae741ee6566.json. Report an issue: GitHub.