So i want to do some python script inside node red to communicate with a S7 PLC. From Odoo btw.
I have installed the python function node but here are the following error:
I have a python script which works when i execute it with the pythonshell node but my problem is i want to edit the script with other nodes. like id numbers which it must retrieve from odoo. So if i can get that python function node to work i can write my script in that.
Or what other node is there that i can use to write the script to a file and then use the pythonshell to execute that file?
That's certainly an interesting issue, but the error shown in the first post, No module named json is striking me as especially odd as this is a builtin module in a default Python installation. It has been present since Python 2.6, if I remember correctly, which was first released in 2008 and has been EOL since 2013. I haven't even seen in it on enterprise systems in a long time. If I had to guess this is because the python-function node first serialises the entire msg object on Node-RED to JSON, then pushes that through an opened file descriptor into the program, so even if you don't use JSON or the JSON module in your project, if the python in your path called can't find those modules you're in trouble.
I've seen similar issues like this with python-function before. The OP is best of using either pythonshell, or an exec node with the script. I personally wouldn't attempt to use the python-function node, if you remember correctly (it has popped up on the forums before), it comes with this usage instruction:
The problem is i need to send some info from odoo.com to the PLC and therefore i need to write a python script. Because the odoo nodes needs git installed and i cant find to do it correctly on the IOT2000...
But i found a way to send parameters into the python script which will help alot. Just need some more examples how to use that parameters.