Registry / workflow / questionary

questionary

JSON →
library2.1.1pypypi✓ verified 27d ago

Questionary is a Python library for effortlessly building elegant command line user prompts. It simplifies querying users for input in CLI applications, offering various question types like text, password, select, checkbox, and confirmation prompts. As of its current version 2.1.1, it is actively maintained with regular updates.

pip install questionary
INSTALL
IMPORT
SIG · QUESTIONARY
Q
questionary
workflowpythonv2.1.1
Install
2.2s avg
Import
565ms
Disk
24MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.596s · 28.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.2s · import 0.534s · 29MB
24MB installed
● package 24MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

questionary
import questionary
Choice
from questionary import Choice
import questionary.Choice
While 'questionary' itself is the main import, specific classes like 'Choice' are typically imported directly from the top-level package.
Validator, ValidationError
from questionary import Validator, ValidationError
prompt
from questionary import prompt
Use `prompt` for a list of questions defined as dictionaries, or direct `questionary.<type>().ask()` for single questions.

This quickstart demonstrates how to use `questionary.text` for free-form input and `questionary.select` for choosing from a list. It also includes basic handling for `Ctrl+C` which causes `ask()` to return `None`.

import questionary def main(): name = questionary.text("What's your name?").ask() if name is None: # User pressed Ctrl+C print("Operation cancelled.") return choice = questionary.select( "What do you want to do?", choices=['Order a pizza', 'Make a reservation', 'Ask for opening hours'] ).ask() if choice is None: print("Operation cancelled.") return print(f"Hello, {name}!") print(f"You chose: {choice}") if __name__ == "__main__": main()
questionary --version
Debug
Known issues
breakingBetween versions 1.6.0 and 1.8.0, the `value` parameter in `Choice` objects began to be implicitly type-cast to `str` upon selection. Applications expecting non-string types (e.g., `int`) to be returned from `select` or `checkbox` prompts may encounter `TypeError` or incorrect logic.
fix
Explicitly cast the returned value to the expected type, or ensure string values are handled correctly in your application logic. Always pass string values to `Choice(..., value='...')` if you require string output, or handle the type conversion after `ask()`.
affects: >=1.8.0
breakingSupport for Python 3.6 and 3.7 was officially deprecated with the release of version 2.0.0. Projects using these older Python versions should upgrade to Python 3.8 or newer.
fix
Upgrade your Python environment to 3.8 or a later compatible version.
affects: >=2.0.0
gotchaThe `checkbox()` prompt does not support the `validate` argument. Attempts to pass a `Validator` or validation function to `checkbox()` will result in an error or unexpected behavior.
fix
Perform validation on the list of selected items *after* the `checkbox().ask()` call has returned. You can iterate through the list and apply custom validation logic.
affects: All versions
gotchaPressing `Ctrl+C` (KeyboardInterrupt) during a prompt will cause `questionary.ask()` methods to return `None` instead of raising an exception. This needs to be explicitly handled in your code if you want to differentiate between user cancellation and a valid answer.
fix
Always check for `None` as a possible return value after calling `.ask()` on any prompt type to gracefully handle user cancellation (e.g., `if answer is None: print('Cancelled'); exit()`).
affects: All versions
gotchaThere are two main ways to ask multiple questions: `questionary.form()` which takes keyword arguments where values are `Question` instances, and `questionary.prompt()` which takes a list of question dictionaries. Mixing these patterns or using the wrong input format for the respective function can lead to errors.
fix
When using `questionary.form()`, pass `questionary.<type>(...).ask()` instances directly to keyword arguments. When using `questionary.prompt()`, provide a list of dictionaries, each defining 'type', 'name', and 'message' keys at a minimum. Refer to the documentation for correct usage of each.
affects: All versions
breakingThe `questionary` library is designed for interactive command-line interfaces and requires a TTY (interactive terminal) to function correctly. Running any `questionary.ask()` prompt in a non-interactive environment (e.g., CI/CD pipelines, Docker containers without `-it` flags, or when standard input is redirected) will result in runtime errors such as `EOFError`, `PermissionError: [Errno 1] Operation not permitted`, `KeyError: '0 is not registered'`, or a 'Input is not a terminal' warning.
fix
Ensure that your application is executed within an interactive terminal environment. If running in a Docker container, use the `-it` flags (e.g., `docker run -it your_image`). For automated tests or non-interactive scripts, consider mocking `questionary` calls or conditionally bypassing interactive prompts based on `sys.stdin.isatty()`.
affects: All versions
breaking`questionary` is an interactive prompt library and requires a TTY (pseudo-terminal) to function correctly. Running `questionary.ask()` methods in non-interactive environments (e.g., CI/CD pipelines, Docker containers without `-it` or `tty` enabled) will result in `PermissionError`, `EOFError`, or similar input/output related errors as it cannot attach to stdin/stdout.
fix
Ensure the application is run in an interactive terminal environment. For Docker, use `docker run -it ...`. For CI/CD, consider mocking the input/output or skipping interactive prompts, or using a library designed for non-interactive user input.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'questionary'
The 'questionary' library has not been installed in the current Python environment.
fix
pip install questionary
TypeError: unsupported operand type(s) for +: 'Text' and 'str'
The '.ask()' method was not called on the questionary prompt object, so the variable holds the prompt object itself instead of the user's input string.
fix
Call '.ask()' at the end of the prompt definition to retrieve the user's input:
answer = questionary.text("What's your name?").ask()
AttributeError: 'NoneType' object has no attribute 'lower'
The user aborted the prompt (e.g., by pressing Ctrl+C or Esc), causing 'questionary.ask()' to return 'None', and subsequent code attempted to call a string method on this 'None' value.
fix
Add a check for 'None' after calling '.ask()' to handle cases where the user aborts the prompt:
answer = questionary.text("Input:").ask()
if answer is not None:
    print(answer.lower())
TypeError: An option must be a string or a tuple (display_value, actual_value)
The 'choices' argument for 'select' or 'checkbox' prompts contains elements that are not strings or valid '(display_value, actual_value)' tuples.
fix
Ensure all items in the 'choices' list are either strings or tuples of two values:
questionary.select("Choose:", choices=["Option 1", "Option 2"]).ask()
Upgrade
Version history
2.1.1latest on PyPI · released Aug 28, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
36 hits · last 30 days
node
26
OpenAI (training)
1
Resources