Installation

Latest release

To install using uv:

uv add python-statemachine

To install using poetry:

poetry add python-statemachine

Alternatively, if you prefer using pip:

python3 -m pip install python-statemachine

Optional extras

Some features require extra dependencies, available as pip extras:

python3 -m pip install "python-statemachine[diagrams]"    # pydot, to generate diagrams from your machines
python3 -m pip install "python-statemachine[yaml]"        # PyYAML, to load YAML statechart documents
python3 -m pip install "python-statemachine[validation]"  # jsonschema, to validate documents (validate=True)
python3 -m pip install "python-statemachine[io]"          # PyYAML + jsonschema, the full JSON/YAML IO stack

Diagram generation also requires the Graphviz system package (see Diagrams). The [yaml], [validation] and [io] extras back the declarative loaders documented in IO and formats; loading JSON needs no extra, as it uses only the standard library.

From sources

The sources for Python State Machine can be downloaded from the Github repo.

You can either clone the public repository:

git clone git://github.com/fgmacedo/python-statemachine

Or download the tarball:

curl  -OL https://github.com/fgmacedo/python-statemachine/tarball/main

Once you have a copy of the source, you can install it with:

python3 -m pip install -e .