# Connection of python script in node red

**URL:** https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770
**Category:** General
**Tags:** exec
**Created:** [16 January 2023 17:34 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770 "2023-01-16T17:34:47Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Pawandeep](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@Pawandeep](https://discourse.nodered.org/u/Pawandeep)
#### Post date: [16 January 2023 17:34 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/1 "2023-01-16T17:34:47Z")

</div>

Hello Everyone,  
I want to ask how to install python libraries in node-red.  
I used a program given on this Node-RED only, where I had to create a python environment and bash flow. But Then there is an error "make is not recognizable as an internal or external command"

---

<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: [16 January 2023 18:11 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/2 "2023-01-16T18:11:44Z")

</div>

> [@Pawandeep](#):
>
> I want to ask how to install python libraries in node-red

You cannot do that since Node-RED is not based on Python but on Node.JS.

> [@Pawandeep](#):
>
> I had to create a python environment and bash flow. But Then there is an error "make is not recognizable as an internal or external command"

So this has nothing to do with dashboard or events - I've changed the tags accordingly.

You need to use the exec node for this. That lets you run OS command line apps from within Node-RED, optionally capturing any output.

In order to access `make` which is a command-line app, you need to make sure that however you are running Node-RED, that the "user" that runs it has a suitable environment set. Most likely, you don't have a correct `path` set so that the command cannot be found.

Better still, from a standard command prompt on the server, issue the command `whereis make` and put the full path to make in your BASH command.

---

<div class="post-metadata">

### Author: ![Pawandeep](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@Pawandeep](https://discourse.nodered.org/u/Pawandeep)
#### Post date: [16 January 2023 20:06 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/3 "2023-01-16T20:06:08Z")

</div>

So how would I run my python script( of detecting real time hand gestures) in node Red?

---

<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: [16 January 2023 20:21 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/4 "2023-01-16T20:21:19Z")

</div>

Call your python script from an Exec node.

---

<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: [16 January 2023 20:25 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/5 "2023-01-16T20:25:58Z")

</div>

> [@Pawandeep](#):
>
> So how would I run my python script( of detecting real time hand gestures) in node Red?

> [@TotallyInformation](#):
>
> You need to use the exec node for this

I already said.

---

<div class="post-metadata">

### Author: ![Pawandeep](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@Pawandeep](https://discourse.nodered.org/u/Pawandeep)
#### Post date: [16 January 2023 20:56 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/6 "2023-01-16T20:56:27Z")

</div>

Okay, I called my python code with exec.  
But then my code consists of libraries cv2, numpy, mediapipe and tensorflow. And therefore I am facing an error in node RED of module not found "cv2".  
What should I do?

---

<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: [16 January 2023 21:30 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/7 "2023-01-16T21:30:03Z")

</div>

> [@Pawandeep](#):
>
> But then my code consists of libraries cv2, numpy, mediapipe and tensorflow. And therefore I am facing an error in node RED of module not found "cv2".  
> What should I do?

> [@TotallyInformation](#):
>
> In order to access `make` which is a command-line app, you need to make sure that however you are running Node-RED, that the "user" that runs it has a suitable environment set. Most likely, you don't have a correct `path` set so that the command cannot be found.

Again, I already said.

The best thing to do is probably create a BASH script that sets everything up including sets the path, sets up a Python virtual env, etc. then calls the script.

---

<div class="post-metadata">

### Author: ![Pawandeep](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@Pawandeep](https://discourse.nodered.org/u/Pawandeep)
#### Post date: [17 January 2023 22:15 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/8 "2023-01-17T22:15:05Z")

</div>

Please, could you tell me how to do that on windows pc. I am totally new to node RED and don't know anything.

---

<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: [18 January 2023 00:24 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/9 "2023-01-18T00:24:01Z")

</div>

Do you know how to set up a Python virtual environment?

You previously mentioned BASH but that isn't the best way to do things on Windows unless you are using WSL. PowerShell is the best scripting environment on Windows, do you know anything about PowerShell?

---

<div class="post-metadata">

### Author: ![Pawandeep](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@Pawandeep](https://discourse.nodered.org/u/Pawandeep)
#### Post date: [18 January 2023 14:56 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/10 "2023-01-18T14:56:11Z")

</div>

Not really.As I told you before, I am completely new to these platforms.  
So which script should I create on powershell in order to run my python code on node RED.  
Could please tell me stepwise?

---

<div class="post-metadata">

### Author: ![ChZeman](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@ChZeman](https://discourse.nodered.org/u/ChZeman)
#### Post date: [18 January 2023 15:38 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/11 "2023-01-18T15:38:06Z")

</div>

Let's take a step back for a moment. Does your python script work fine outside of Node Red? What will Node Red's function in all of this be?

---

<div class="post-metadata">

### Author: ![Pawandeep](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@Pawandeep](https://discourse.nodered.org/u/Pawandeep)
#### Post date: [18 January 2023 16:56 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/12 "2023-01-18T16:56:32Z")

</div>

Yes my python file is to detect hand gestures.  
I need to join my python file and ERP bar( it is available on google to look at) with webservices. So that when I show a specific hand gestures on the webcam it would return initiation of specific step in production process of the drink, ERP bar makes.  
My python files consist of certain packages like mediapipe, cv2, numpy and tensorflow, therefore whenever I am using exec node to run my python script, there is an error that indicates, I need to download all those packages of python script in nodeRED as well.  
I am attaching a screenshot of the error.

 ![2023-01-18.png](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/3/43ac97ab1c628c4e42afb0e3bfaf8209ed3a20be.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: [18 January 2023 19:13 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/13 "2023-01-18T19:13:48Z")

</div>

> [@Pawandeep](#):
>
> indicates, I need to download all those packages of python script in nodeRED as well.

You need to think about your Windows and Python environments. You also need to know how you are starting Node-RED.

If everything on the Python side works by issuing some Python command at a Windows command prompt and if you are starting Node-RED manually - both with the same user, then everything should just work.

So clearly you are either starting Node-RED a different way which means that it doesn't have the same environemnt settings. Or, there is something you are not revealing to us about running the Python side from the command line.

So what we need now is the output from the Node-RED log from the point of it starting up to the point where it says "flows started". Then we need to see the output from you running the Python part manually from the command line.

---

<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: [19 March 2023 19:14 UTC](https://discourse.nodered.org/t/connection-of-python-script-in-node-red/73770/14 "2023-03-19T19:14:20Z")

</div>

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