Reputation: 71
I have used the spawn module to call a script1.py function from my nodejs export handler but it does not work. The index.js file is as follows-:
exports.handler = async function(event, context) {
process.env['PATH'] = process.env['PATH'] + ':' + process.env['LAMBDA_TASK_ROOT']
//this was added as mentioned in the aws documentation
let dataToSend
const python = spawn('python', ['script1.py']);
python.stdout.on('data', function (data) {
console.log('Pipe data from python script ...');
dataToSend = data.toString();
});
console.log("EVENT: \n" + JSON.stringify(event, null, 2)+ dataToSend)
return dataToSend
}
and the python script1.py is as follows-:
print('hello from python')
I tested it using postman and it gave an internal server error. I want to run a spacy module hence I need to integrate my python code with my nodejs code.
Upvotes: 0
Views: 874
Reputation: 21530
This will not work, because there is no Python installed in the NodeJS runtime.
As far as I can tell, you have three options:
Upvotes: 1