# Python

Run Python on live and recorded data

- Category: Tools
- Capabilities: Engine, Operations
- Runs on: Linux x64, Linux ARM64, macOS Apple silicon, macOS Intel, Windows x64

Run Python code from Phloem. The agent and Trellis can evaluate expressions and
run snippets to process signals, compute values or drive custom logic.

## What you get

- **Operations** — `eval` (run an expression), plus a connection test.
- Each call runs in a fresh `python -c` process. Imports and variables do not
  carry over between calls.

## Setup

1. Install the connector from the **Connectors** tab and open its page.
2. Point it at your Python environment, then press **Test** to confirm.

## Computed channels

A computed channel runs your function over a window of a signal and publishes
the result as a new channel. Your function gets one window:

```python
def my_metric(win):
    # win["t_us"] — sample times, microseconds since 1970-01-01 UTC
    # win["value"] — the sample values, same order
    return max(win["value"]) - min(win["value"])
```

Return one number, or a dict of names to numbers for several outputs. Times
are **microseconds**; divide by 1,000,000 for seconds.

## Notes

- Put everything one computation needs, imports included, in one snippet.

## Connection fields

| Field | Type | Required | Notes |
|---|---|---|---|
| Python interpreter path | Text | No |  |
