@background404/node-red-contrib-python-venv 0.5.3

Node for python virtual environment

npm install @background404/node-red-contrib-python-venv

node-red-contrib-python-venv

Node to use Python virtual environment in Node-RED

GitHub Sponsor npm version npm downloads GitHub Discussions

If you would like to find a sample flow or have questions, please visit GitHub Discussions page!

Overview

With this node, you can run Python in Python's virtual environments in Node-RED.

When you install this node, python virtual environment (pyenv folder) is also created.
You can run python(.exe) or pip(.exe) in that environment.

Sample flows are in the examples folder.
sample-flow.png

Nodes

venv node

python(.exe) is in the ./pyenv/Scripts/python.exe or Python virtual environment you have added.

Write your Python code in the node.
The program is saved in the virtual environment and executed.

venv-node.jpg

You can access Node-RED messages like print(msg['payload']).

msg-property.png

You can also access flow and global objects like print(node['flow']['payload']), print(node['global']['payload']).

msg-property-flow-global.png

The number of running nodes is displayed in the status.

running-status.png

pip node

pip(.exe) is in the ./pyenv/Scripts/pip.exe or Python virtual environment you have added.

You can run pip commands like install, uninstall, list.
Select the commands.

pip-node.jpg

This node uses pip in the virtual environment, so it is different from the existing Python environment packages.
Please compare.

pip-list.jpg

venv-exec

This node can execute executable files in Scripts or bin folder.

venv-exec.jpg

You can see the name of the executable in List Executables mode.
Then you can execute it with arguments in Execute mode.

venv-exec-list.jpg venv-exec-execute.jpg

venv-config (config node)

You can create and switch between multiple Python virtual environments.
You need to add and set the name of the virtual environment.
You can also specify the Python version only in Windows.
venv-config.png

When a configuration node is deleted, the virtual environment with that name is also deleted.
If you add a node with the same venv Name, only one virtual environment will be created.

The nodes can be executed by creating virtual environments even if the venv Name contains spaces or is an absolute path.
venv-config-abspath.png

Other Links

Technical Articles

I refer to "Creating Nodes" page of Node-RED.
https://nodered.org/docs/creating-nodes/

My article: Creating Nodes for Node-RED Part 1 (python-venv)
https://404background.com/en/programming/creating-nodes-1/

My article: python-venv node development history (2024)
https://qiita.com/background/items/3244fc1b70cc454befef

Nodes created based on this node

voicevox-core node: Node that outputs Japanese audio files using voicevox-core
https://flows.nodered.org/node/@background404/node-red-contrib-voicevox-core

whisper node: Node to transcribe text using Open AI's Whisper
https://flows.nodered.org/node/@background404/node-red-contrib-whisper

Node Info

Version: 0.5.3
Updated 3 weeks, 2 days ago
License: MIT
Rating: 5.0 5

Categories

Actions

Rate:

Downloads

61 in the last week

Nodes

  • venv
  • pip
  • venv-config
  • venv-exec

Keywords

  • node-red
  • python

Maintainers