py_trees
pythonic implementation of behaviour trees
Decision gist · record as of 2026-08-14
Yes. py_trees is actively maintained, has low install friction, carries no known vulnerabilities, and offers a clean abstraction for hierarchical decision-making. Install it if you are building a robotics system, game AI, or any medium-complexity state machine that benefits from tree-structured control flow and shared state management.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python wheel with a single runtime dependency (pydot).
- Actively maintained with a recent release; last commit 2026-07-16 and support for modern Python versions including 3.14.
License · maintenance · safety
BSD (permissive) — BSD permissive license allows use in commercial and proprietary projects with minimal restrictions; retain license notice in distributions.
last release 2026-07-14 (31 days) · last repo commit 2026-07-16 · 632 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 192,161 downloads/mo, #9,868 on PyPI
Alternatives
Verify before relying
pip install py_trees
import py_trees
# Create a simple behavior tree
root = py_trees.composites.Sequence(name="Root", memory=False)
root.add_child(py_trees.behaviours.Success(name="Task"))
tree = py_trees.trees.BehaviourTree(root=root)
tree.setup_with_descendants()
tree.tick_once()- Whether pydot is required at runtime or only for visualization features
- Exact Python version floor for current releases (requires_python is unspecified)
What it is and what it does
py_trees is a Python library for building behaviour trees—hierarchical, composable decision-making structures commonly used in robotics and game AI. It provides core primitives like behaviours (leaf nodes representing actions), decorators (wrappers that modify behaviour), composites (sequences, selectors, parallels that combine children), and a blackboard system for sharing state across the tree. Trees can be constructed programmatically or declaratively via XML, serialized to dot graphs for visualization, and rendered in the terminal.
The library is designed for medium-sized decision engines where you need to orchestrate complex conditional logic and state management without writing deeply nested if-else chains. It includes a library of ready-made behaviours and idioms, plus tools for introspection and debugging. Recent versions add typed input/output ports for behaviours and a ForEach decorator for iteration patterns.
Use it for
- Build a robot control layer that sequences sensor checks, decision logic, and motor commands using tree composites.
- Implement game AI that selects actions (attack, flee, heal) based on game state stored in a shared blackboard.
- Create a workflow engine where tasks are behaviours and control flow (try-catch, retry, parallel execution) is expressed as tree structure.
- Visualize and debug decision logic by rendering the tree to ASCII/Unicode or exporting to dot graphs.
- Define complex conditional logic declaratively in XML rather than imperative code, then parse and execute it at runtime.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
py_trees is actively maintained, has low install friction, carries no known vulnerabilities, and offers a clean abstraction for hierarchical decision-making. Install it if you are building a robotics system, game AI, or any medium-complexity state machine that benefits from tree-structured control flow and shared state management.
Install
py-trees on PyPI
Before you install
Low friction: pure Python wheel with a single runtime dependency (pydot). Actively maintained with a recent release; last commit 2026-07-16 and support for modern Python versions including 3.14.
License in practice
BSD permissive license allows use in commercial and proprietary projects with minimal restrictions; retain license notice in distributions.
Quickstart
pip install py_trees
import py_trees
# Create a simple behavior tree
root = py_trees.composites.Sequence(name="Root", memory=False)
root.add_child(py_trees.behaviours.Success(name="Task"))
tree = py_trees.trees.BehaviourTree(root=root)
tree.setup_with_descendants()
tree.tick_once()
Verify before relying
- Whether pydot is required at runtime or only for visualization features
- Exact Python version floor for current releases (requires_python is unspecified)
Package facts
| License | BSD permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepydot |
| Maintenance | Actively maintained 31 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 192,161 / month, #9,868 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Environment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseProgramming Language :: PythonTopic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Software Development :: Libraries |
Evidence: py_trees-2.5.0-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “behaviour tree implementation”
- py_treespy_trees implements behaviour trees in Python, providing composable…
- treelibProvides a simple tree data structure implementation for Python,…
- red-black-tree-modProvides Python implementations of red-black trees with optional…
Give your agent the search over MCP, or paste the wish link into any chat.
More Libraries packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Provides parsing, arithmetic, and recurrence rule computation for dates and times, with timezone support and iCalendar RFC compliance.
Install it if you need to parse flexible date strings, compute relative dates, handle timezones, or work with recurrence rules—it's the de facto choice for these tasks.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
See also dtreeviz · tensorflow-decision-forests · treelite-runtime · treelite · ydf · pyjpt · skope-rules · rules · optree · red-black-tree-mod