Note: There are ways to tweak this configuration, feel free to change things! This instructions are intended to be the most direct path to get python up and running on your machine.
-
Elgato Stream Deck (tested with Elgato Stream Deck V1, but should work with any model).
-
Stream Deck Software (https://www.elgato.com/en/downloads).
-
Windows 10 system (have not needed to distribute on Linux/Mac yet).
-
python-3.8or higher (https://realpython.com/installing-python/#how-to-install-from-the-full-installer).Make sure that the
pythonexecutable is in your system path (https://docs.python.org/3/using/windows.html#setting-envvars)
Open a command line in the project folder. Create a virtual environment with the following command:
.../streamdeck_python_plugin/> python -m venv .venvActivate this new virtual environment:
.../streamdeck_python_plugin/> .venv\Scripts\activate.batMake sure pip is up-to-date:
.../streamdeck_python_plugin/> python -m pip install --upgrade pipInstall packages from requirements.txt file:
.../streamdeck_python_plugin/> pip install -r requirements.txtCreating a Stream Deck python plugin consists of 4 steps.
com.basic-python-plugin.py is where the Elgato Stream Deck runs code from.
The Plugin().process_data() function is where actions can be performed based on updates from the Stream Deck app:
...
def process_data(self, data):
"""Process data and perform actions.
Args:
data (dict): Data dictionary.
"""
logging.info(f"Processing data: {data}")
self.state = self.state + 1
logging.info(f"Testing state: {self.state}")
try:
if "payload" in data:
if self.sd_context is None:
self.sd_context = data["context"]
except Exception as err:
logging.critical(err)Based on the data from the app, different actions can be programmed.
To create the executable pyinstaller will be used. Navigate to the plugin folder and run the following command to create the executable:
.../streamdeck_python_plugin/streamcom.streamdeck-basic-python-plugin.sdPlugin/plugin> pyinstaller com.basic-python-plugin.pyThis will create a dist and build folder in the plugin folder.
The path to the executable will be plugin/dist/com.basic-python-plugin.exe.
Note:
pyinstallerwill find all imports and include them in the build. There are some external libraries where additional setup is needed, in which case some customization will be needed (https://pyinstaller.readthedocs.io/en/stable/operating-mode.html#analysis-finding-the-files-your-program-needs)
If no modifications are made to the image filenames and the executable path doesn't change, the manifest.json can be left as is.
Otherwise, this documentation from Elgato is a good reference for how to set up the json: https://developer.elgato.com/documentation/stream-deck/sdk/manifest/
Reference: https://developer.elgato.com/documentation/stream-deck/sdk/exporting-your-plugin/
Finally, to install the plugin in the Stream Deck app, Elgato has provided a distribution tool for both Mac and Windows.
For the next step, open a shell in the parent directory of the plugin folder. For example, if the plugin folder was C:/Desktop/com.streamdeck-basic-python-plugin.sdPlugin, then the shell would need to be running from C:/Desktop.
Run this command from the command line in the project folder:
.../streamdeck_python_plugin/> tools/DistributionTool.exe -b -i com.streamdeck-python-plugin.sdPlugin -o releasecom.streamdeck-python-plugin.sdPlugin is the plugin folder (not the python executable), and the value after -o is where to put the distribution file.
In the above case , you should find a com.streamdeck-python-plugin.streamDeckPlugin file in com.streamdeck-python-plugin.sdPlugin/release.
Double clicking com.streamdeck-python-plugin.streamDeckPlugin will install your plugin.
During development, if you make changes to the plugin code and rebuild it, you will need to uninstall the old plugin first before installing the updated plugin in the Stream Deck App.
MAKE SURE YOU ARE NOT ACCESSING THE APP PLUGIN FOLDER WHEN YOU DOUBLE CLICK/RUN com.streamdeck-python-plugin.streamDeckPlugin (C:\Users\\(user)\AppData\Roaming\Elgato\StreamDeck\Plugins\\(plugin-name) for Windows). The uninstall will not complete properly if so and you may have to restart your system, close the Stream Deck app, and delete the plugin folder manually from the App Plugin folder as an administrator.
WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of ...\python\python39\python39.dll
Solutions:
-
Uninstall and re-install python
Do not have a good explanation for this fix other than that it worked for me. May be that the python paths were not set up properly.
