pypa/pip · error · Exception

No input was expected ($PIP_NO_INPUT set); question: {messag

Error message

No input was expected ($PIP_NO_INPUT set); question: {message}

What it means

A plain Exception raised by _check_no_input when PIP_NO_INPUT is set in the environment and pip needs to ask an interactive question (confirmation/deletion prompt). Setting PIP_NO_INPUT declares 'never prompt me'; pip honors that by failing instead of blocking on stdin, which is essential for non-interactive CI.

Source

Thrown at src/pip/_internal/utils/misc.py:253

    n = 1
    extension = ext
    while os.path.exists(dir + extension):
        n += 1
        extension = ext + str(n)
    return dir + extension


def ask_path_exists(message: str, options: Iterable[str]) -> str:
    for action in os.environ.get("PIP_EXISTS_ACTION", "").split():
        if action in options:
            return action
    return ask(message, options)


def _check_no_input(message: str) -> None:
    """Raise an error if no input is allowed."""
    if os.environ.get("PIP_NO_INPUT"):
        raise Exception(
            f"No input was expected ($PIP_NO_INPUT set); question: {message}"
        )


def ask(message: str, options: Iterable[str]) -> str:
    """Ask the message interactively, with the given possible responses"""
    while 1:
        _check_no_input(message)
        response = input(message)
        response = response.strip().lower()
        if response not in options:
            print(
                "Your response ({!r}) was not one of the expected responses: "
                "{}".format(response, ", ".join(options))
            )
        else:
            return response

View on GitHub (pinned to d7d0d0a394)

Solutions

  1. Set PIP_EXISTS_ACTION=a (or the relevant action: b/c/w/s) so pip never needs to ask about existing paths.
  2. Pre-clean the target (rm the conflicting dir or uninstall first) so no prompt is needed.
  3. If interactivity is actually fine, unset PIP_NO_INPUT and run in a TTY.
  4. Pass the corresponding flag directly (e.g. --exists-action a) instead of relying on the env var.

Example fix

# before
export PIP_NO_INPUT=1
pip install pkg   # hits 'target dir exists' prompt → Exception

# after
export PIP_NO_INPUT=1
export PIP_EXISTS_ACTION=a
pip install pkg
Defensive patterns

Strategy: validation

Validate before calling

import os

def ensure_noninteractive_safe(exists_action=None):
    if os.environ.get('PIP_NO_INPUT') and not exists_action:
        # set a default action so pip never blocks on a path-exists prompt
        os.environ.setdefault('PIP_EXISTS_ACTION', 'a')
# call before any pip invocation in CI

Try / catch

try:
    pip_install(pkg)
except Exception as e:
    if 'PIP_NO_INPUT set' in str(e):
        os.environ['PIP_EXISTS_ACTION'] = 'a'
        pip_install(pkg)
    else:
        raise

Prevention

When it happens

Trigger: os.environ.get('PIP_NO_INPUT') is truthy and ask()/ask_path_exists() is called — e.g. a target directory already exists and PIP_EXISTS_ACTION doesn't resolve it, or an uninstall needs to confirm deletion of files outside the prefix.

Common situations: CI/docker with PIP_NO_INPUT=1 (or PIP_NO_INPUT set globally) where pip hits a path-exists prompt because PIP_EXISTS_ACTION isn't set; uninstalling a package that installed files outside the tracked prefix; installing into a venv whose target dir conflicts.

Related errors


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