# Python 3 function & Node-red disconnected

**URL:** <https://discourse.nodered.org/t/python-3-function-node-red-disconnected/7275>\
**Category:** General\
**Created:** [26 January 2019 17:18 UTC](https://discourse.nodered.org/t/python-3-function-node-red-disconnected/7275 "2019-01-26T17:18:02Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![emspe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/emspe/32/5421_2.png) [@emspe](https://discourse.nodered.org/u/emspe)\
**Post date:** [28 January 2019 07:43 UTC](https://discourse.nodered.org/t/python-3-function-node-red-disconnected/7275/21 "2019-01-28T07:43:55Z")

</div>

Thank you for the clarification & the suggestion. I will try this.

---

<div class="post-metadata">

**Author:** ![jk2020](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jk2020/32/7864_2.png) [@jk2020](https://discourse.nodered.org/u/jk2020)\
**Post date:** [27 April 2019 11:08 UTC](https://discourse.nodered.org/t/python-3-function-node-red-disconnected/7275/22 "2019-04-27T11:08:08Z")

</div>

I am also struggling with the python3 node; using pyhtonshell node as a work around for the time being to execute a python script and it works perfectly.  
At the example above I believe there are brakets missing and code should be as follows:

```auto
[{"id":"2dd28338.06ea0c","type":"inject","z":"76982441.84c0cc","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":380,"wires":[["78a3aac2.86168c"]]},{"id":"78a3aac2.86168c","type":"exec","z":"76982441.84c0cc","command":"python -u -c \"for r in range(10): print ('hello world\\n')\"","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":480,"y":380,"wires":[["b8129d5f.eba96"],["5c2a80b5.e9ba6"],[]]},{"id":"b8129d5f.eba96","type":"debug","z":"76982441.84c0cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":360,"wires":[]},{"id":"5c2a80b5.e9ba6","type":"debug","z":"76982441.84c0cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":400,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 April 2019 13:29 UTC](https://discourse.nodered.org/t/python-3-function-node-red-disconnected/7275/23 "2019-04-27T13:29:33Z")

</div>

> [@jk2020](#):
>
> I am also struggling with the python3 node;

if you look at the Info tab for node-red-contrib-python3 you will see:  
 ![python3_warn](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7a04fde27d6089a9f07bc969479cc8ef8effc803.png)

(I put the red box in.) Also note that the node has not been updated in over 2 years....

---

<div class="post-metadata">

**Author:** ![johestephan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johestephan/32/12905_2.png) [@johestephan](https://discourse.nodered.org/u/johestephan)\
**Post date:** [16 August 2019 08:43 UTC](https://discourse.nodered.org/t/python-3-function-node-red-disconnected/7275/24 "2019-08-16T08:43:56Z")

</div>

Hi all,

as the code has not been updated in some years the main issue could be that the "spawn" command still uses a pretty old style. You can check

> .node-red/node\_modules/node-red-contrib-python3-function/lib/python3-function.js

there you can find the line

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

make sure it uses the right python version

---

<div class="post-metadata">

**Author:** ![moisesStevend](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/moisesstevend/32/43579_2.png) [@moisesStevend](https://discourse.nodered.org/u/moisesStevend)\
**Post date:** [20 June 2021 01:35 UTC](https://discourse.nodered.org/t/python-3-function-node-red-disconnected/7275/25 "2021-06-20T01:35:57Z")

</div>

Guys, I solved that problem, just writing this command on an AWS terminal Linux:  
$ sudo apt-get install python-is-python3

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 June 2021 07:02 UTC](https://discourse.nodered.org/t/python-3-function-node-red-disconnected/7275/26 "2021-06-20T07:02:32Z")

</div>



[Previous page](https://discourse.nodered.org/t/python-3-function-node-red-disconnected/7275.md?page=1)
