"node-red-contrib-python-functions" does not come to.

1,331 views
Skip to first unread message

kovaccs

unread,
Sep 15, 2016, 4:09:47 PM9/15/16
to Node-RED

I installed the mentioned 3rd party node and restarted Node-RED. After that I can't find the installed node in my Node-RED system.
I tried it load several time and different methodes without success. npm ended no errors, python 2.7 is installed. There is node-red-contrib-python-function directory inside ~/.node-red/node_modules/

Have anybody some suggestion what I doing wrong? I've got a large number of used extra nodes insatlled.

Kovaccsaba

Mark Setrem

unread,
Sep 15, 2016, 5:06:29 PM9/15/16
to Node-RED
It would be useful if you shared a little bit about your setup

What are you running node-red on?
What version of node-red?
What version of nodejs?

Dave C-J

unread,
Sep 15, 2016, 6:27:08 PM9/15/16
to node...@googlegroups.com
also their readme is a bit hit and miss...
If you install using the default
    cd ~/.node-red
    npm i node-red-contrib-python-function 
Then is works for me...
(you don't need the -g)

Walter Kraembring

unread,
Sep 16, 2016, 5:06:46 AM9/16/16
to Node-RED
This is a cool node, been looking for something like this,

Anyone knows "how to" or where to put additional .py files to import into the node. Like mosquitto.py

Currently the following fails

import mosquitto.py
with error
Traceback (most recent call last): File "<string>", line 101, in <module> File "<string>", line 59, in python_function ImportError: No module named mosquitto.py


as well as

import /home/pi/mosquitto.py
with error
File "<string>", line 60 import /home/pi/mosquitto.py ^ SyntaxError: invalid syntax


kovaccs

unread,
Sep 16, 2016, 7:46:02 AM9/16/16
to Node-RED

Mark Stern:  Base hadware:  Raspberry Pi 3
pi@kovaccs-rPI-deb:~ $ node-red -v


Welcome to Node-RED
===================

16 Sep 13:42:54 - [info] Node-RED version: v0.14.3
16 Sep 13:42:54 - [info] Node.js  version: v0.12.6
16 Sep 13:42:54 - [info] Linux 4.4.17-v7+ arm LE
16 Sep 13:42:54 - [info] Loading palette nodes
16 Sep 13:43:05 - [info] UI started at /ui
16 Sep 13:43:12 - [warn] ------------------------------------------------------
16 Sep 13:43:12 - [warn] [python-function] SyntaxError: /usr/local/lib/node_modules/node-red-contrib-python-function/lib/python-function.js:6
    return fnCode.split('\n').map((line) => Array(depth).join(' ') + line).joi
                                         ^^
Unexpected token =>
16 Sep 13:43:12 - [warn] ------------------------------------------------------
16 Sep 13:43:12 - [info] Settings file  : /home/pi/.node-red/settings.js
16 Sep 13:43:12 - [info] User directory : /home/pi/.node-red
16 Sep 13:43:12 - [info] Flows file     : /home/pi/.node-red/flows_kovaccs-rPI-deb.json
16 Sep 13:43:12 - [warn] Communication server error: Error: listen EADDRINUSE
16 Sep 13:43:12 - [error] Unable to listen on http://127.0.0.1:1880/
16 Sep 13:43:12 - [error] Error: port in use
pi@kovaccs-rPI-deb:~ $

Nicholas O'Leary

unread,
Sep 16, 2016, 7:47:39 AM9/16/16
to Node-RED

From that error message, it appears that node requires node.js 4.x or later as it uses the newer ES6 syntax.

Nick


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Walter Kraembring

unread,
Sep 16, 2016, 8:11:35 AM9/16/16
to Node-RED
Yes, I upgraded node.js to 4.5.0 and then it worked

I used these commands to upgrade node.js (but after I had to npm-install some of my nodes again) so maybe there is a better way doing it

sudo npm cache clean -f
sudo npm install -g n
sudo n 4.5.0

 

kovaccs

unread,
Sep 16, 2016, 12:16:10 PM9/16/16
to Node-RED

Walter Kaembring:
I've tried to execute your cli offers.
It has more trouble than there was. :(

---
pi@kovaccs-rPI-deb:~ $ sudo npm cache clean -f
npm WARN using --force I sure hope you know what you are doing.
pi@kovaccs-rPI-deb:~ $ sudo npm install -g n
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/request/node_modules/aws4 requires lru-cache@'^4.0.0' but will load
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/lru-cache,
npm WARN unmet dependency which is version 2.6.4
n...@2.1.4 /usr/local/lib/node_modules/n
pi@kovaccs-rPI-deb:~ $ sudo n 4.5.0

     install : node-v4.5.0
       mkdir : /usr/local/n/versions/node/4.5.0
       fetch : https://nodejs.org/dist/v4.5.0/node-v4.5.0-linux-armv7l.tar.gz
######################################################################## 100,0%
   installed : v4.5.0

pi@kovaccs-rPI-deb:~ $ cd ~/.node-red
pi@kovaccs-rPI-deb:~/.node-red $  npm i node-red-contrib-python-function
npm ERR! Linux 4.4.17-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "node-red-contrib-python-function"
npm ERR! node v4.5.0
npm ERR! npm  v2.15.9
npm ERR! path /home/pi/.node-red/node_modules/node-red-contrib-python-function
npm ERR! code EISGIT

npm ERR! git Appears to be a git repo or submodule.
npm ERR! git     /home/pi/.node-red/node_modules/node-red-contrib-python-function
npm ERR! git Refusing to remove it. Update manually,
npm ERR! git or move it out of the way first.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/pi/.node-red/npm-debug.log

content of npm-debug.log:
pi@kovaccs-rPI-deb:~/.node-red/node_modules/node-red-contrib-python-function $ cat npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'install' ]
2 info using n...@2.15.9
3 info using no...@v4.5.0
4 verbose readDependencies loading dependencies from /home/pi/.node-red/package.json
5 error install Couldn't read dependencies
6 verbose stack Error: ENOENT: no such file or directory, open '/home/pi/.node-red/package.json'
6 verbose stack     at Error (native)
7 verbose cwd /home/pi/.node-red/node_modules/node-red-contrib-python-function
8 error Linux 4.4.17-v7+
9 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
10 error node v4.5.0
11 error npm  v2.15.9
12 error path /home/pi/.node-red/package.json
13 error code ENOPACKAGEJSON
14 error errno -2
15 error syscall open
16 error package.json ENOENT: no such file or directory, open '/home/pi/.node-red/package.json'
16 error package.json This is most likely not a problem with npm itself.
16 error package.json npm can't find a package.json file in your current directory.
17 verbose exit [ -2, true ]
pi@kovaccs-rPI-deb:~/.node-red/node_modules/node-red-contrib-python-function $

I dont know who erased the settings.js and package.json files!???

Try to install manually python-function nod....

pi@kovaccs-rPI-deb:~/.node-red/node_modules $ cd node-red-contrib-python-function/
pi@kovaccs-rPI-deb:~/.node-red/node_modules/node-red-contrib-python-function $ git clone https://github.com/arnauorriols/node-red-contrib-python-function.git
Cloning into 'node-red-contrib-python-function'...
remote: Counting objects: 22, done.
remote: Total 22 (delta 0), reused 0 (delta 0), pack-reused 22
Unpacking objects: 100% (22/22), done.
Checking connectivity... done.
pi@kovaccs-rPI-deb:~/.node-red/node_modules/node-red-contrib-python-function $ npm install
npm ERR! install Couldn't read dependencies
npm ERR! Linux 4.4.17-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.5.0
npm ERR! npm  v2.15.9
npm ERR! path /home/pi/.node-red/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno -2
npm ERR! syscall open

npm ERR! package.json ENOENT: no such file or directory, open '/home/pi/.node-red/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/pi/.node-red/node_modules/node-red-contrib-python-function/npm-debug.log
pi@kovaccs-rPI-deb:~/.node-red/node_modules/node-red-contrib-python-function $

Unfortunately Node-RED doesn't start after.

pi@kovaccs-rPI-deb:~ $ node-red-start

Start Node-RED

Once Node-RED has started, point a browser at http://172.30.1.240:1880
On Pi Node-RED works better with the Firefox browser

Use   node-red-stop                          to stop Node-RED
Use   node-red-start                         to start Node-RED again
Use   node-red-log                           to view the recent log output
Use   sudo systemctl enable nodered.service  to autostart Node-RED at every boot
Use   sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to http://flows.nodered.org
You may also need to install and upgrade npm
      sudo apt-get install npm
      sudo npm i -g npm@2.x

Started Node-RED graphical event wiring tool..
Error loading settings file: /home/pi/.node-red/settings.js
[Error: Module version mismatch. Expected 46, got 14.]
^C
pi@kovaccs-rPI-deb:~ $

Is it possible to rehabilitate or I'm starting install from 0 status?
 
Kovaccsaba

Walter Kraembring

unread,
Sep 16, 2016, 2:31:53 PM9/16/16
to Node-RED
I did not experience those problems but try to move the settings file to another place (with winscp, move to a harddrive away from node-red, keep a copy!!!)
Then start node-red and I think a new settings.js will be created

kovaccs

unread,
Sep 16, 2016, 5:01:46 PM9/16/16
to Node-RED

Yes, I've done it before. There is a new settings.sj on .nod-red directory, but the Node-RED doesn't start even.

Dave C-J

unread,
Sep 16, 2016, 5:06:20 PM9/16/16
to node...@googlegroups.com
It may be too messed up by now... but... 
you may be able to run our default upgrade script...
   update-nodejs-and-nodered
This should uninstall old nodejs and replace with version 4.5 and the latest node-red
fingers crossed

Nicholas O'Leary

unread,
Sep 16, 2016, 5:19:28 PM9/16/16
to Node-RED Mailing List
Just to explain the error you are seeing, some node modules include binary components that need to be compiled for the version of node.js you want to use them with. Here you've upgraded your instance of node.js, but not rebuilt any of the modules you have - this is the 'module version mismatch' you see.



--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

kovaccs

unread,
Sep 16, 2016, 5:25:53 PM9/16/16
to Node-RED

Dave C-J:

This has been done and it has not helped!

I've got a nodjs V.4.5 installed

pi@kovaccs-rPI-deb:~ $ nodejs -v
v4.5.0

Nicholas O'Leary

unread,
Sep 16, 2016, 5:27:38 PM9/16/16
to Node-RED Mailing List
In ~/.node-red, run 'npm rebuild' and see where you get to.

kovaccs

unread,
Sep 16, 2016, 5:31:27 PM9/16/16
to Node-RED
Nick O'Leary


Just to explain the error you are seeing, some node modules include binary components that need to be compiled for the version of node.js you want to use them with. Here you've upgraded your instance of node.js, but not rebuilt any of the modules you have - this is the 'module version mismatch' you see.

It seems to a good approach, how to compile this components?

Kovaccsaba

kovaccs

unread,
Sep 16, 2016, 5:42:12 PM9/16/16
to Node-RED
Here is  the npm rebuild task result: (attached the npm-debug.log)

pi@kovaccs-rPI-deb:~/.node-red $ npm rebuild

> bcr...@0.8.7 install /home/pi/.node-red/node_modules/bcrypt
> node-gyp rebuild

make: Entering directory '/home/pi/.node-red/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
  SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
  COPY Release/bcrypt_lib.node
make: Leaving directory '/home/pi/.node-red/node_modules/bcrypt/build'

> ic...@2.1.11 install /home/pi/.node-red/node_modules/irc/node_modules/iconv
> node-gyp rebuild

make: Entering directory '/home/pi/.node-red/node_modules/irc/node_modules/iconv/build'
  CC(target) Release/obj.target/libiconv/deps/libiconv/lib/iconv.o
  AR(target) Release/obj.target/iconv.a
  COPY Release/iconv.a
  CXX(target) Release/obj.target/iconv/src/binding.o
  SOLINK_MODULE(target) Release/obj.target/iconv.node
  COPY Release/iconv.node
make: Leaving directory '/home/pi/.node-red/node_modules/irc/node_modules/iconv/build'
npm ERR! Linux 4.4.17-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "rebuild"
npm ERR! node v4.5.0
npm ERR! npm  v2.15.11
npm ERR! path /home/pi/.node-red/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall unlink

npm ERR! Error: EACCES: permission denied, unlink '/home/pi/.node-red/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, unlink '/home/pi/.node-red/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'unlink',
npm ERR!   path: '/home/pi/.node-red/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.


npm ERR! Please include the following file with any support request:
npm ERR!     /home/pi/.node-red/npm-debug.log
pi@kovaccs-rPI-deb:~/.node-red $

Kovaccsaba



2016. szeptember 16., péntek 23:27:38 UTC+2 időpontban Nick O'Leary a következőt írta:
In ~/.node-red, run 'npm rebuild' and see where you get to.
On 16 September 2016 at 22:25, kovaccs <kovac...@gmail.com> wrote:

Dave C-J:

This has been done and it has not helped!

I've got a nodjs V.4.5 installed

pi@kovaccs-rPI-deb:~ $ nodejs -v
v4.5.0

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
npm-debug.log

Nicholas O'Leary

unread,
Sep 16, 2016, 5:44:10 PM9/16/16
to Node-RED Mailing List
As it says, try running as root:

    sudo npm rebuild

Nick

To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

kovaccs

unread,
Sep 16, 2016, 5:45:43 PM9/16/16
to Node-RED
yes, yes, yes, I realised I'm wrong sorry!!!!

kovaccs

unread,
Sep 16, 2016, 6:09:54 PM9/16/16
to Node-RED
So! The npm rebuilt is solved a lot trouble. The system working again. It should be a little more refined, because the serial ports are disappeared...

Thank you for your attention and help, especially for Nick and the others who replied!
And sorry for this long conversations.

Have a nice weekend!
  Kovaccsaba

Dave C-J

unread,
Sep 16, 2016, 6:30:02 PM9/16/16
to node...@googlegroups.com
Hi yes serial ports also have a binary part to them - but are installed as part of the core (normally) - so the update to them is slightly different. If you are feeling strong we can attempt to fix that tomorrow :-)

kovaccs

unread,
Sep 16, 2016, 8:11:01 PM9/16/16
to Node-RED
Oh Dave, it wold be fine, because I haven't serial port at this moment.
But tomorow I'll be in road full day... I'm gouing to sign if I can working on node-red. Thank you!

Kovaccsaba

Walter Kraembring

unread,
Sep 17, 2016, 1:57:54 PM9/17/16
to Node-RED
Anyone knows "how to" or where to put additional .py files to import into the node

I think I can answer this myself now. Maybe interesting for others as well. In my case, as example, I wanted to have access to a weather api that I have used earlier in pure Python programs. It can be found here:
https://code.google.com/archive/p/python-weather-api/

What I did I simply built it from source according instructions but I used admin rights (sudo, maybe overkill but I did it)

After this, it works perfect, just do "import pywapi". Motivated by this *success* I did the same with paho (pip install paho-mqtt). So now I can do a lot of "other stuff" in Python as well and also send MQTT messages directly from my Python code 

Best regards, Walter

kovaccs

unread,
Sep 17, 2016, 4:38:55 PM9/17/16
to Node-RED


2016. szeptember 17., szombat 0:30:02 UTC+2 időpontban Dave C-J a következőt írta:
Hi yes serial ports also have a binary part to them - but are installed as part of the core (normally) - so the update to them is slightly different. If you are feeling strong we can attempt to fix that tomorrow :-)


Hi Dave,

I'm here again, and aren't feel strong myself :-)
If you online, would you be so kind to help fix the serialport issue?

Kovaccsaba

kovaccs

unread,
Sep 17, 2016, 4:42:09 PM9/17/16
to Node-RED
This is my versions:
RPI 3, Linux 4.4.17-v7+ arm LE
Node-RED version: v0.14.6
Node.js  version: v4.5.0
npm version: 2.15.11


2016. szeptember 17., szombat 0:30:02 UTC+2 időpontban Dave C-J a következőt írta:
Reply all
Reply to author
Forward
0 new messages