pypa/pip · error · PipError

Could not determine editor to use.

Error message

Could not determine editor to use.

What it means

Raised by `pip config edit` when no editor can be determined. _determine_editor at configuration.py:281 checks --editor, then $VISUAL, then $EDITOR; if all three are absent/None it raises this PipError. pip has no built-in default editor.

Solutions

  1. Pass the editor explicitly: `pip config edit --editor nano`.
  2. Set EDITOR (or VISUAL) in your shell: `export EDITOR=nano` (add to ~/.bashrc/~/.zshrc).
  3. Edit the file manually — run `pip config debug` to find its path, then open it in any editor.

Example fix

// before
pip config edit
// after
export EDITOR=nano
pip config edit
Defensive patterns

Strategy: validation

Validate before calling

# Ensure an editor is resolvable before pip config edit
import os, shutil

def resolve_editor(explicit=None):
    ed = explicit or os.environ.get("VISUAL") or os.environ.get("EDITOR")
    if not ed or not shutil.which(ed.split()[0]):
        raise EnvironmentError("No editor: set EDITOR or pass --editor")
    return ed

Prevention

When it happens

Trigger: Running `pip config edit` without --editor and with neither VISUAL nor EDITOR exported in the environment.

Common situations: Minimal containers, CI shells, fresh user accounts, or non-interactive shells where no editor env var is set.

Related errors


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

Appendix: 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 f399c37189)