arnauorriols / node-red-contrib-python-function

Write Python functions in Node-RED!
MIT License
41 stars 23 forks source link

Is there a way of using Python3 inside the function node instead of Python2.7? #9

Closed ramuyk closed 4 years ago

ramuyk commented 4 years ago

I'd like to use the python function node using Python3 instead of Python2.7... I've tried directly editing the file ~/.node-red/node_modules/node-red-contrib-python-function/lib/python-function.js as the following:

  function spawnFn(self) {
    self.child = spawn('python3', ['-uc', self.func.code], {stdio: ['pipe', 'pipe', 'pipe', 'ipc']});
    ...
  }

Then I restart Node-RED... But I always get a sequence of errors if I try to do it. I've also tried to manually change the system command "python" to run "python3" instead (I use Ubuntu 18.04) but I got the same errors. Is it possible to use this python function on Node-RED with python3?

ramuyk commented 4 years ago

I've solved it using this other node that is already made for python3:

node-red-contrib-python3-function

ramuyk commented 4 years ago

arnauorriols commented 4 years ago

FWIW, I've just incorporated the fix of @rafaelmuynarsk and will release it shortly!