Cannot get python node to work

I installed the node-red-contrib-python-function using

npm install -g node-red-contrib-python-function

and the package was added successfully.

However, if I try to use the python node, I get an error:

File "C:\Python38\lib\json_init_.py", line 343, in loads
s = s.decode(detect_encoding(s), 'surrogatepass')
File "C:\Python38\lib\encodings\utf_32_le.py", line 11, in decode
return codecs.utf_32_le_decode(input, errors, True)
UnicodeDecodeError: 'utf-32-le' codec can't decode bytes in position 16-19: code point not in range(0x110000)

The JSON of my Node-RED project is extremely simple

[{"id":"7bc803fa.fe25ac","type":"tab","label":"1","disabled":false,"info":""},{"id":"d3811b80.53c9e8","type":"inject","z":"7bc803fa.fe25ac","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":" { "id": "datapoint1", "value": "124.6215", "timestamp": "1601477603842888960" }","payloadType":"json","x":240,"y":180,"wires":[["de1f02dd.008a9"]]},{"id":"de1f02dd.008a9","type":"python-function","z":"7bc803fa.fe25ac","name":"","func":"\nreturn msg","outputs":1,"x":490,"y":180,"wires":[["2b9229e3.b17286"]]},{"id":"2b9229e3.b17286","type":"debug","z":"7bc803fa.fe25ac","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":780,"y":180,"wires":}]

Have you asked the contrib node author?

I think others have had problems with that node, the solution is often to use an exec node instead.

Or... add MQTT to your python script so it talks to NR in a common method of communication, but it all depends on what the python script is doing, if this is a reasonable option. I have a lot of existing python that I would rather not just replace in NR. So I added MQTT support to much of my python, which made integration of python results into NR, just about painless.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.