-
Couldn't load subscription status.
- Fork 223
Closed
Description
I'm using the following to call my python script:
var PythonShell = require('python-shell');
var pyshell = new PythonShell.run('/home/pi/Development/Sensor/python/SenseHat.py');
// get message back
pyshell.on('message', function (message) {
// received a message sent from the Python script (a simple "print" statement)
console.log(message);
});
// end the input stream and allow the process to exit
pyshell.end(function (err) {
if (err) throw err;
console.log('exit');
});
If I use the full path to the script it fails with the error below:
/home/pi/Development/Sensor/node/pythonTest.js:14
if (err) throw err;
^
Error: python: can't open file 'home/pi/Development/Sensor/python/SenseHat.py': [Errno 2] No such file or directory
at PythonShell.parseError (/home/pi/node_modules/python-shell/index.js:190:17)
at terminateIfNeeded (/home/pi/node_modules/python-shell/index.js:98:28)
at Socket.<anonymous> (/home/pi/node_modules/python-shell/index.js:78:9)
at emitNone (events.js:72:20)
at Socket.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:903:12)
at doNTCallback2 (node.js:439:9)
at process._tickCallback (node.js:353:17)
If I use the following path to the script it all works ok:
../python/SenseHat.py
and so does:
../../../../../home/pi/Development/Sensor/python/SenseHat.py