Outils pour utilisateurs

Outils du site


start:raspberry:nodered:python

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
start:raspberry:nodered:python [2025/01/29 11:00] – créée adminstart:raspberry:nodered:python [2025/02/03 17:08] (Version actuelle) – [Utilisation de python dans node-red] admin
Ligne 1: Ligne 1:
 ======== Installation python dans node-red ======== ======== Installation python dans node-red ========
 +
 +[[https://flows.nodered.org/search?term=python| Librairie Python pour Node-red EN ]]
  
 ====installation de python-shell==== ====installation de python-shell====
  
-    sudo npm install node-red-contrib-pythonshell +    sudo npm install node-red-contrib-python-shell 
-     +== Usage == 
-    + 
 +Exécution d'un script Python depuis node-red. L'entrée du nœud deviendra l'argument du script Python, la sortie du script sera envoyée à la sortie du nœud. 
 + 
 +L'exécution dans un environnement virtuel est désormais prise en charge. Spécifiez le chemin d'accès au dossier virtualenv dans la configuration du nœud.     
 + 
 +==Exemple de script Python == 
 + 
 +Et voici le contenu du script python : 
 + 
 +<code python exemple002.py> 
 + 
 +import sys 
 +print "Got arguments: ", sys.argv 
 +</code> 
 +==== Installation d'un noeud Python-Fonction ==== 
 +      sudo npm install node-red-contrib-python-function-ps --save 
 +==Usage== 
 + 
 +Comme le nœud de fonction, écrivez du code Python au lieu du code JavaScript et exécutez-le. 
 + 
 +<code python exemple001.py> 
 +# user code here. 
 + 
 +a = 1234 
 + 
 +node.globals["a"] = a 
 +del node.globals["a"
 + 
 +write_output("a", a) 
 +msg["payload"] = read_input("a"
 + 
 +return msg 
 +</code> 
 + 
 +===== Utilisation de python dans node-red ===== 
 + 
 +[[https://flowfuse.com/blog/2024/07/calling-python-script-from-node-red/|Script Python et Node-Red EN ]]
  
 +[[https://funprojects.blog/2023/10/26/mix-node-red-and-python/|Mixez Python et Node-red avec un Robot piloter via un Raspberry EN]]
/home/chanteri/www/fablab37110/data/attic/start/raspberry/nodered/python.1738144843.txt.gz · Dernière modification : 2025/01/29 11:00 de admin