PyInquirer has been revived. The original project was abandoned in 2024 with the maintainer asking for a successor. This fork picks up where it left off — Python 3.10+ support, modern prompt_toolkit compatibility, and active maintenance.
- Python 3.10, 3.11, 3.12 support — Fixed
collections.Mappingand deprecatedpygments.token.Tokenimports that broke on 3.10+ - prompt_toolkit 3.x compatibility — Updated dependency bounds to support all prompt_toolkit 3.x releases
- CI via GitHub Actions — Tests run on Python 3.8 through 3.12 on every push
- Bug fixes — Fixed separator styling for list prompts, improved error handling
PyInquirer is a collection of common interactive command line user interfaces, based on Inquirer.js.
pip install PyInquirerIf you encounter any prompt_toolkit errors, ensure you have the correct version:
pip install prompt_toolkit>=3.0.0,<4.0.0from PyInquirer import prompt
questions = [
{
'type': 'input',
'name': 'first_name',
'message': "What's your first name",
}
]
answers = prompt(questions)
print(answers)PyInquirer supports the following question types:
| Type | Description |
|---|---|
input |
Free-form text input |
confirm |
Yes/no confirmation |
list |
Single selection from a list |
rawlist |
Numbered list selection |
expand |
Expandable choice list with key shortcuts |
checkbox |
Multi-select from a list |
password |
Masked text input |
editor |
Opens external editor for input |
See the examples/ directory for usage examples of each question type:
- input.py — Basic text input
- confirm.py — Yes/no prompts
- list.py — Single choice from a list
- checkbox.py — Multiple selections
- password.py — Masked input
- editor.py — External editor integration
- expand.py — Expandable choices
- pizza.py — Full pizza ordering demo using multiple question types
- hierarchical.py — Conditional questions with
when
Each question dictionary supports these properties:
type— Question type (input, confirm, list, rawlist, expand, checkbox, password, editor)name— Key name in the answers dictionarymessage— The prompt message shown to the userdefault— Default value if no input is givenchoices— List of choices (for list, rawlist, checkbox, expand)validate— Validation function receiving user inputfilter— Transform function applied to the answerwhen— Conditional function to decide if the question should be askedpageSize— Number of visible lines in list-type prompts
Custom styles can be applied using prompt_toolkit's Style:
from prompt_toolkit.styles import Style
custom_style = Style.from_dict({
'questionmark': '#E91E63 bold',
'answer': '#2196F3 bold',
'pointer': '#FF9800 bold',
'selected': '#4CAF50',
'separator': '#9E9E9E',
})
answers = prompt(questions, style=custom_style)Original project created by Oyetoke Toby. This fork is maintained by Zafrul Razeem.
MIT — see LICENSE for details.