I am able to call my python from nodejs on AWS Lambda using the below function. However, because I need specific python libraries, I created a virutalenv in the env directory. I zipped everything up and pushed to Lambda. But when I try and call python from the virtual directory I get a Permission Denied error.
I attempted to modify the chmod permissions on Lambda before calling python but got Operation Not Permitted. How can I get this to run?
console.log('Loading event');
var exec = require('child_process').exec;
exports.handler = function(event, context) {
exec('env/bin/python district.py \'' + JSON.stringify(event) + '\'', function(error, stdout) {
var obj = stdout.toString();
context.done(error, obj);
});
};
Here's the error:
{
"errorMessage": "Command failed: /bin/sh: env/bin/python: Permission denied\n",
"errorType": "Error",
"stackTrace": [
"",
"ChildProcess.exithandler (child_process.js:658:15)",
"ChildProcess.emit (events.js:98:17)",
"maybeClose (child_process.js:766:16)",
"Process.ChildProcess._handle.onexit (child_process.js:833:5)"
]
}