pypa/pip · error · Exception
No input was expected ($PIP_NO_INPUT set); question
Error message
No input was expected ($PIP_NO_INPUT set); question: {message} What it means
Raised as a generic Exception by _check_no_input (misc.py:253) when the PIP_NO_INPUT environment variable is set and pip needs to ask the user an interactive question (confirmation prompt, choice selection, or password). Setting PIP_NO_INPUT (equivalent to --no-input) tells pip to never prompt for input; if it reaches a code path that requires input, it fails immediately rather than hanging on a blocked stdin. This is essential for non-interactive CI/automation.
Solutions
- Set PIP_EXISTS_ACTION=a (or the relevant action letters) to auto-answer file-exists prompts without interaction.
- Provide credentials via environment variables (PIP_INDEX_USER, PIP_INDEX_PASSWORD), a keyring, or a netrc file instead of interactive prompts.
- Remove PIP_NO_INPUT if you actually want interactive prompts.
- Pre-resolve the condition causing the prompt (e.g. clean the target directory, pin versions to avoid conflicts).
Example fix
// before export PIP_NO_INPUT=1 pip install pkg # hits overwrite confirmation // 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_no_prompt_conflicts():
"""Set PIP_EXISTS_ACTION and credentials before PIP_NO_INPUT to avoid prompts."""
if os.environ.get('PIP_NO_INPUT'):
os.environ.setdefault('PIP_EXISTS_ACTION', 'a') # auto-overwrite
if not (os.environ.get('PIP_INDEX_USER') or os.path.get('PIP_INDEX_URL')):
print('Warning: PIP_NO_INPUT set but no non-interactive credentials configured.') Prevention
- Always pair PIP_NO_INPUT=1 with PIP_EXISTS_ACTION to handle overwrite prompts.
- Provide index credentials via env vars or netrc rather than interactive prompts.
- Test pip commands in CI before deploying to ensure no hidden prompt triggers.
When it happens
Trigger: PIP_NO_INPUT=1 is set (or --no-input passed) and pip encounters a situation requiring a prompt: ask(), ask_path_exists(), ask_input(), or ask_password() all call _check_no_input first (lines 261, 275, 281). Examples: a file-exists confirmation, a keyring/Git credential prompt, or a dependency conflict that needs a user decision.
Common situations: CI pipelines with PIP_NO_INPUT=1 where pip needs confirmation for an overwrite (PIP_EXISTS_ACTION not set). Docker builds with --no-input that encounter a package needing credential input for a private index. Automation scripts that set PIP_NO_INPUT globally and hit an unexpected prompt.
Related errors
- Can not perform a '--user' install. User site-packages are…
- Can not perform a '--user' install. User site-packages are…
- Can't add %r to environment
- Cannot find command - invalid PATH
- Could not determine appropriate file.
AI-assisted analysis of pypa/pip@f399c37189 (2026-08-08).
Data as JSON: /api/errors/dc611c7f51ce114f.
Report an issue: GitHub.
Appendix: 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 f399c37189)