Node-red contrib pythonshell

Hello everybody :slight_smile:

Please, I need your help!
I want to start a python3 script from a node.
For this I installed "node-red-contrib-pythonshell", works well with an easy script, but now i want to import "requests" modul and I always get this error:

exit code: 1, Traceback (most recent call last):
File "kodi-pause.py", line 3, in
import requests
ModuleNotFoundError: No module named 'requests'

And I really have no idea why?
I have created a virtual environment in the data directory of node-red and installed "request" in it. If I change to the environment from the console and start the script, its working fin, but not from the node.

I have no more ideas what to do and so every tip is welcome!
Thanks in front and have a nice weekend!
Mili

Hi and welcome to the forum.

Can I ask, what is your end goal? To control a Kodi device?

Have you tried the Kodi nodes?

If you are just trying to do http requests, there is the built in http request node.

Yes, that is a part of what I want to do, but there are many more python scripts, that I have wrote and i want them integreted.
Kodi nodes will only be a workaround.
And I hate to program in Java and love Python! :smiley:

And overall I want to understut why it don´t work.

But thanks for your tips!

Then you're in luck, node-red is JavaScript.

But seriously, why not put the efforts in, learn to do things in native way, I promise you will love it just as much.

1 Like

While learning more & more about Node-RED & javascript, you can use the excellent EXEC node to start & run & recycle your existing Python script without problems. I have done this myself since years now. If you in addition need to exchange data between your Python scripts and Node-RED you can easily use MQTT. After some time you may even migrate some of your Python scripts and replace them with functionality provided by Node-RED. At least this is how I started to learn, coming from a pure Python and C++ environment

2 Likes

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