API Reference
Invoke
A Python task execution and command-line library for managing shell-oriented automation tasks.
Official Documentation ↗CompatibilityThis documentation covers version
v2.2. Check the official docs for the latest API surface.Installation
pip
pip install invokeMethods
No methods match this filter.
Invoke turns functions into CLI tasks with argument parsing and a context for running commands.
Key Features
- Task decorator and namespace collection
- Context run and sudo helpers
- Config-driven task defaults
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The official API reference declares the following error types:
invoke.exceptions.AuthFailure(exception) — official text: “exception invoke.exceptions.AuthFailure(result: Result, prompt: str) — An authentication failure, e.g. due to an incorrect sudo password.” (source: https://docs.pyinvoke.org/en/stable/api/exceptions.html#invoke.exceptions.AuthFailure, fetched 2026-11-08T16:03:08.4363995+08:00)invoke.exceptions.UnexpectedExit(exception) — official text: “exception invoke.exceptions.UnexpectedExit(result: Result, reason: str)” (source: https://docs.pyinvoke.org/en/stable/api/exceptions.html#invoke.exceptions.UnexpectedExit, fetched 2026-11-08T16:03:08.4363995+08:00)invoke.exceptions.CommandTimedOut(exception) — official text: “exception invoke.exceptions.CommandTimedOut(result: Result, timeout: int)” (source: https://docs.pyinvoke.org/en/stable/api/exceptions.html#invoke.exceptions.CommandTimedOut, fetched 2026-11-08T16:03:08.4363995+08:00)
API reference evidence
Fetched from official sources on 2026-11-08T16:03:08.4363995+08:00 via WebFetch 官方 API 页面(context / tasks / exceptions).
@task→ signature from https://docs.pyinvoke.org/en/stable/api/tasks.html#invoke.tasks.task; official text: “invoke.tasks.task(*args: Any, **kwargs: Any) → Callable — Marks wrapped callable”Context.run→ signature from https://docs.pyinvoke.org/en/stable/api/context.html#invoke.context.Context.run; official text: “run(command: str, **kwargs: Any) → Result — Execute a local shell command, honoring config options.”Context.sudo→ signature from https://docs.pyinvoke.org/en/stable/api/context.html#invoke.context.Context.sudo; official text: “sudo(command: str, **kwargs: Any) → Result — Execute a shell command via sudo with password auto-response.”
FAQ
- How do I list tasks?
- Run inv --list to show all discovered tasks and their arguments.
- How do I set default arguments?
- Use the task decorator options or an invoke.yaml config so tasks read defaults from configuration.
- How is Invoke different from Fabric?
- Invoke runs local commands; Fabric extends it to remote hosts over SSH, sharing the task model.
Report a problem with this API docOpens a pre-filled issue on GitHub.