Interactive Prompts
Interactive prompts collect user input for wizards, confirmations, and guided setup. Use Click's built-in prompts for simple cases; questionary for rich selection UIs.
Search across all documentation pages
Interactive prompts collect user input for wizards, confirmations, and guided setup. Use Click's built-in prompts for simple cases; questionary for rich selection UIs.
import questionary
name = questionary.text("Project name:").ask()
framework = questionary.select("Framework?", choices=["FastAPI", "Django", "Flask"]).ask()
confirmed = questionary.confirm("Proceed?").ask()When to reach for this:
cookiecutter-style)import questionary
from rich.console import Console
console = Console()
def run_setup_wizard() -> dict:
if not questionary.confirm("Run interactive setup?").ask():
raise SystemExit("Aborted")
answers = {
"name": questionary.text("Project name:", validate=lambda t: len(t) > 0 or "Required").ask(),
"framework": questionary.select(
"Web framework:",
choices=["FastAPI", "Django", "Flask"],
).ask(),
"database": questionary.checkbox(
"Features:",
choices=["postgres", "redis", "celery"],
).ask(),
"deploy": questionary.select(
"Deployment target:",
choices=["Docker", "Lambda", "VPS"],
).ask(),
}
if not questionary.confirm(f"Create {answers['name']} with {answers['framework']}?").ask():
raise SystemExit("Aborted")
return answers
if __name__ == "__main__":
config = run_setup_wizard()
console.print(f"[green]Creating project: {config}[/green]")What this demonstrates:
| Library | Best for |
|---|---|
click.confirm/prompt | Simple confirm/text |
questionary | Select, checkbox, autocomplete |
prompt_toolkit | Full custom REPL |
InquirerPy | Alternative to questionary |
CI=true or --yes flag to skip prompts.confirm().questionary.password() or click.prompt(hide_input=True).| Alternative | Use When | Don't Use When |
|---|---|---|
| CLI flags only | Scriptable automation | Guided first-time setup |
| web-based setup | Complex configuration | Terminal-only tool |
| config file | Repeatable deploys | Initial onboarding |
click.prompt for simple text/confirm. questionary for select, checkbox, autocomplete.
if os.environ.get("CI"): use defaults or --yes / --non-interactive flag.
questionary returns None on cancel. Check and exit gracefully.
questionary.password("API key:").ask().
questionary.autocomplete("Path:", choices=file_list).ask().
questionary supports style dictionaries for colors.
Mock questionary.text(...).ask() return values in pytest.
Chain prompts in functions; show progress with Rich.
Building a full REPL or syntax-highlighted input. Heavier than questionary.
questionary.select(..., default="FastAPI").ask().
Stack versions: This page was written for Python 3.14.0, FastAPI 0.115+, Django 5.2, Flask 3.1, Pydantic 2, PyTorch 2.6+, pandas 2.2+, Polars 1.x, ruff 0.9+, and uv 0.6+.
Reviewed by Chris St. John·Last updated Jul 19, 2026