4 Run platypush in a virtual environment
Fabio Manganiello edited this page 2021-09-17 00:01:11 +02:00

You can run a Platypush instance in a Python virtual environment. There are several advantages for this option:

  • You won't have to install dependencies at system level and you can easily create instances in user space
  • The available tools will take care for the required dependencies depending on your configuration. Just write your config.yaml and Platypush will figure out which dependencies are required by the plugins you wish to use
  • You can easily copy environments to other machines, as all the required dependencies and configuration for the application to run will all be inside of the ~/.local/share/platypush/<my-device> folder
  • You can create multiple instances on the same machine and easily start, stop and remove them. Note however that this option will use more disk space compared to a system installation if you decide to use virtual environments: each environment will install its own set of dependencies instead of relying on those available on the system.

The project comes with platyvenv, a script that should be installed in your bin path upon Platypush installation. You can use it to build, remove, start, stop and list Platypush virtual environments. Note that both python-venv and platypush need to be installed on your host system for these steps to work.


  1. Create your own config.yaml file for a Platypush instance:

    level: INFO

    engine: sqlite:////home/user/.local/share/platypush/venv/my-device/usr/share/db/platypush.db

    token: YOUR_TOKEN
    device: platypush/your_device

        host: localhost
        port: 6397

    host: YOUR_MQTT_HOST

    port: 3333

    port: 8765

    port: 8008

    language: en-US

    ifttt_key: YOUR_IFTTT_KEY

            key: KEY_1
            key: KEY_2
  1. Build a virtual environment out of the configuration file using platyvenv:
platyvenv build -c /path/to/config.yaml

Note that platyvenv will inspect your configuration file, automatically identify the required dependencies and install them in your virtual environment.

  1. Start the new environment:
platyvenv start my-device

The output of the Platypush service is printed on the terminal.

  1. After it's started up, if everything went smooth, you should already be able to send messages to the new environment over the available exposed service. For example, over JSON-RPC:
curl -XPOST -H 'Content-Type: application/json' \
    -d '{"type":"request", "action":"shell.exec", "args": {"cmd":"hostname"}}' \
    http://localhost:8008/execute | jq
  1. Stop a running instance:
platyvenv stop my-device
  1. Remove an environment:
platyvenv rm my-device