Exec script to UI app

First of all, thanks everyone to take your time to help. English is not my mature language and I apologize beforehand for that.

I have a node with exec easy sentence: script.md

The code in script.md is:
lxterminal python3 my_script.py

It wouldn't be a problem unless I'm working with opencv dependencies, and I have to see the camera output on the monitor.
If I run the script from terminal, it just works. But through the node-red, I always have the same issue:
(lxterminal:1604): Gtk-WARNING **: cannot open display:

lxterminal is because i'm working in a raspberry pi.

PD: I use node-red because I want to run this script when the device receive a message in a broker/topic. If you have any other suggestion to do that I'll be grateful to learn :slight_smile:


You are running a script using the GTK toolkit that requires access to a desktop GUI. In fact, you are using the LXDE's desktop terminal app to run a PYTHON programme and you don't need to do that.

Your script should simply be python3 my_script.py. And for that, you can simply add that command to a Node-RED exec node. The output of the script will be returned as a msg to Node-RED and you can output it or process it as needed.

And just to add, if you really want to show the script running on the monitor, you can use a command like this in the exec node:

export DISPLAY=:0 && lxterminal -e python3 /home/pi/my_script.py

Thanks both for answer. I'll try on monday.

My best try to get my goal was adding a "watchdog" python script in crontab and use it for lauch my python3 my_script.
It worked but isn't a good way to solve.

Thanks again you for your time and consideration.