Search code examples
pythonraspberry-pi

NPM won't install serialport on raspberry pi 1b


I ran npm install serialport but I get a python error

alfred@alfred:~/AccentaG4/src/mpu/server $ python --version
Python 3.9.2

> @serialport/[email protected] install /home/alfred/AccentaG4/src/mpu/server/node_modules/@serialport/bindings
> prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild

prebuild-install warn install No prebuilt binaries found (target=11.15.0 runtime=node arch=arm libc= platform=linux)
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /usr/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                       ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:299:12)
gyp ERR! stack     at ChildProcess.emit (events.js:193:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:999:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:403:11)
gyp ERR! stack     at Socket.emit (events.js:193:13)
gyp ERR! stack     at Pipe._handle.close (net.js:614:12)
gyp ERR! System Linux 6.1.21+
gyp ERR! command "/usr/local/node-v11.15.0-linux-armv6l/bin/node" "/usr/local/node-v11.15.0-linux-armv6l/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/alfred/AccentaG4/src/mpu/server/node_modules/@serialport/bindings
gyp ERR! node -v v11.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN [email protected] requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of utf-8-validate@>=5.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @serialport/[email protected] install: `prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @serialport/[email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Heres the full log

https://docs.google.com/document/d/1awB3tnTxyS4MEFdzmloECIoeFzl9fGo2UjV6OjwOVnE/edit?usp=sharing

I am wondering do


Solution

  • print without brackets is not allowed in python 3.

    print "%s.%s.%s" % sys.version_info[:3];
    

    ↑ is a python 2 syntax, for python 3 it should looks like ↓

    print("%s.%s.%s" % sys.version_info[:3])
    

    Your node and node-gyp versions are outdated. Newer versions of node-gyp support python 3

    If it not possible to update node libraries in your environment you have to downgrade default python version to 2