Zenoh-Flow provides a Zenoh-based data flow programming framework for computations that span from the cloud to the device.
- Rust: see the installation page
- Python >= 3.8
- pip >= 22
- virtualenv
If it's not already the case, start by activating a virtual environment:
$ python3 -m virtualenv venv
$ source venv/bin/activate
sys.path
variable of the Python interpreter with the location of the site-packages folder of the currently active virtual environment. To do so, we rely on the $VIRTUAL_ENV
environment variable. If your favorite environment manager does not set this variable then the zenoh_flow_python
module will not be found when launching your flow.
Build the Python Wheel within a Python virtual environment.
(venv) $ git clone https://github.com/eclipse-zenoh-flow/zenoh-flow-python
(venv) $ cd zenoh-flow-python/zenoh-flow-python
(venv) $ pip3 install -r requirements-dev.txt
(venv) $ maturin build --release
(venv) $ pip install ./target/wheels/<there should only be one .whl file here>
Build the Python wrappers.
$ cargo build --release -p zenoh-flow-python-operator-wrapper -p zenoh-flow-python-sink-wrapper -p zenoh-flow-python-source-wrapper
This error indicates that the Zenoh-Flow runtime was not properly configured to support nodes written in Python.
You need to change the configuration of Zenoh-Flow to let it know how to load Python scripts.
If you launched the Zenoh-Flow runtime in a standalone fashion, you need to provide a configuration that contains the following:
- file_extension: py
libraries:
# Linux
sink: /path/to/zenoh-flow-python/target/release/libzenoh_flow_python_sink_wrapper.so
operator: /path/to/zenoh-flow-python/target/release/libzenoh_flow_python_operator_wrapper.so
source: /path/to/zenoh-flow-python/target/release/libzenoh_flow_python_source_wrapper.so
# macOS
# sink: /path/to/zenoh-flow-python/target/release/libzenoh_flow_python_sink_wrapper.dylib
# operator: /path/to/zenoh-flow-python/target/release/libzenoh_flow_python_operator_wrapper.dylib
# source: /path/to/zenoh-flow-python/target/release/libzenoh_flow_python_source_wrapper.dylib
If you launched Zenoh-Flow as a Zenoh plugin, you need to update the Zenoh configuration with the following:
{
"plugins": {
"zenoh_flow": {
"name": "my-zenoh-flow",
"extensions": [
{
"file_extension": "py",
"libraries": {
// Linux
"operator": "/path/to/zenoh-flow-python/target/release/libzenoh_flow_python_operator_wrapper.so",
"sink": "/path/to/zenoh-flow-python/target/release/libzenoh_flow_python_sink_wrapper.so",
"source": "/path/to/zenoh-flow-python/target/release/libzenoh_flow_python_source_wrapper.so",
// macOS
// "operator": "/path/to/zenoh-flow-python/target/release/libzenoh_flow_python_operator_wrapper.dylib",
// "sink": "/path/to/zenoh-flow-python/target/release/libzenoh_flow_python_sink_wrapper.dylib",
// "source": "/path/to/zenoh-flow-python/target/release/libzenoh_flow_python_source_wrapper.dylib",
}
}
]
}
}
}
First, check that you have activated your virtual environment before launching the Zenoh-Flow runtime (be it through the standalone daemon, runtime or dedicated Zenoh plugin). Make sure that the environment variable $VIRTUAL_ENV
is set.
If your virtual environment is activated, check that the Zenoh-Flow Python package is indeed installed:
- Open a terminal.
- Enter the Python interpreter:
python
- Try to import Zenoh-Flow Python:
import zenoh_flow_python
If you still have the above error when launching your data flow, try reinstalling the package:
- Open a terminal.
cd
intozenoh-flow-python/zenoh-flow-python
.- Build:
maturin build --release
- Install:
pip install ../target/wheels/*.whl --force-reinstall
Try again relaunching your data flow.