# Python-function doesn't finish

**URL:** https://discourse.nodered.org/t/python-function-doesnt-finish/71151
**Category:** General
**Created:** [24 November 2022 00:05 UTC](https://discourse.nodered.org/t/python-function-doesnt-finish/71151 "2022-11-24T00:05:59Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![ErikTavares](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eriktavares/32/71191_2.png) [@ErikTavares](https://discourse.nodered.org/u/ErikTavares)
#### Post date: [24 November 2022 00:05 UTC](https://discourse.nodered.org/t/python-function-doesnt-finish/71151/1 "2022-11-24T00:05:59Z")

</div>

Python Funcion is running, but it doesn't finish.

 ![python_function](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7fee38d9d3b1944db568a024b44ff12d83cb1fa4.png)

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [24 November 2022 00:41 UTC](https://discourse.nodered.org/t/python-function-doesnt-finish/71151/2 "2022-11-24T00:41:09Z")

</div>

You'll need to give us a few more clues!

---

<div class="post-metadata">

### Author: ![ErikTavares](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eriktavares/32/71191_2.png) [@ErikTavares](https://discourse.nodered.org/u/ErikTavares)
#### Post date: [24 November 2022 11:57 UTC](https://discourse.nodered.org/t/python-function-doesnt-finish/71151/3 "2022-11-24T11:57:12Z")

</div>

The function is empty, with only the default return msg. I don't know if you have to install something else for it to work.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [24 November 2022 12:06 UTC](https://discourse.nodered.org/t/python-function-doesnt-finish/71151/4 "2022-11-24T12:06:58Z")

</div>

A function node does nothing at all unless a message arrives at the input.  
If the only code in it is `return msg;` then all it does is pass the msg from input to output.

So I conclude that your function is not actually running.  
Do you have any code in the "On Start" and "On Stop" tabs?

---

<div class="post-metadata">

### Author: ![ErikTavares](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eriktavares/32/71191_2.png) [@ErikTavares](https://discourse.nodered.org/u/ErikTavares)
#### Post date: [24 November 2022 12:42 UTC](https://discourse.nodered.org/t/python-function-doesnt-finish/71151/5 "2022-11-24T12:42:40Z")

</div>

I think the python-function does'n have guides "On Start" and "On Stop".

 ![python_func](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/c/8ccfc0bb8e1a890ccf0ab13b86a25813571c2f1a.jpeg)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [24 November 2022 13:24 UTC](https://discourse.nodered.org/t/python-function-doesnt-finish/71151/6 "2022-11-24T13:24:39Z")

</div>

To get that to do anything you have to pass it a message.

---

<div class="post-metadata">

### Author: ![ErikTavares](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eriktavares/32/71191_2.png) [@ErikTavares](https://discourse.nodered.org/u/ErikTavares)
#### Post date: [24 November 2022 13:28 UTC](https://discourse.nodered.org/t/python-function-doesnt-finish/71151/7 "2022-11-24T13:28:39Z")

</div>

You don't need to set up a python environment for python-function to work?

Uploading: python\_func2.jpg...

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [24 November 2022 15:13 UTC](https://discourse.nodered.org/t/python-function-doesnt-finish/71151/8 "2022-11-24T15:13:30Z")

</div>

> [@ErikTavares](#):
>
> The function is empty, with only the default return msg. I don't know if you have to install something else for it to work.

I don't think it is not finishing. You haven't asked it to start.

---

<div class="post-metadata">

### Author: ![ErikTavares](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eriktavares/32/71191_2.png) [@ErikTavares](https://discourse.nodered.org/u/ErikTavares)
#### Post date: [24 November 2022 17:42 UTC](https://discourse.nodered.org/t/python-function-doesnt-finish/71151/9 "2022-11-24T17:42:53Z")

</div>

there is a tutorial [Install python and create virtual environments directly from the node-red editor (flow) - Node-RED](https://flows.nodered.org/flow/778859ca2503db35ff0e12341508efef/in/vL27qorhYRSn)  
about to create python environment for Node-RED. The second line doen't work on Windows because it uses the chmod command. Command is only a linux command.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [23 January 2023 17:42 UTC](https://discourse.nodered.org/t/python-function-doesnt-finish/71151/10 "2023-01-23T17:42:58Z")

</div>

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