From Python script to Node RED

Hello there,

Is there a way to execute a while python script in my PC and display this informations one by one in Node-RED?

My Python script is:

count = 0
while count < 10:
count += 1
But what displays in the screen is:


How can I displays these information in separate payloads without having to run the script over and over?

If that’s your real script why not recreate it in javascript?

If you really want use python how are you executing the python script? are you using the contrib-node or are you using the exec node?

If the only point is to separate the payloads why not to use the standard split node from the pallete?

Thank you for the reply!
I am using exec node.
This script is an exemple for a bigger one, and unfortunately I can’t use a python3 function node.

Thank you for the reply.
I have another python script that has not built-in libraries, my idea is to use Exec Node to run this script and the script will run a while for an undetermined time.

add a delay in the python script and set the exec node output to:
while the command is running - spawn mode

import time
count = 0
while count < 10:
	count += 1
1 Like

oh my god, thank you for the reply!
The change exec node output solve my problem o/

Hi, I'm trying to do something similar, but I need to have a message for each print within the loop.
Now I can only get one message at the and of the script. This since I have a never ending while loop.
Of course I set the node in spawn mode

is this using a python script ? If so did you use the -u option as per the info ?

1 Like

Done :slight_smile:
just putting "python -u patch" instead of "python patch" in the exec node command
thanks a lot