首页 > 解决方案 > 无法在 Alexa 应用程序中调用 child_process

问题描述

我有一个基于 Alexa 的 lambda 函数,我试图在调用 python 函数时生成一个图形。然后 python 模块将生成的图上传到 s3。两者都可以自己正常工作,但是,在 lambda 中运行时,尝试使用子进程调用它们的 python 模块时会抛出错误。进程没有返回任何内容,节点应用程序中没有任何内容使用 python 模块中的任何内容。不知道我在这里做错了什么......

const PlotDataIntentHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'IntentRequest'
        && handlerInput.requestEnvelope.request.intent.name === 'PlotDataIntent';
  },
  handle(handlerInput) {
    let speechText  = ``;
    const spawn = require("child_process").spawn;
    //simple.py is just a hello world module, but even that won't run
    const pythonProcess = spawn('python',["./pythonModules/simple.py"]);
    speechText = "Successfully ran python module";
    return  handlerInput.responseBuilder
    .speak(speechText)
    .getResponse();
  }

};

标签: pythonnode.js

解决方案


推荐阅读