【问题标题】:Using Python script in NodeJS on GAE在 GAE 上的 NodeJS 中使用 Python 脚本
【发布时间】:2019-05-02 04:44:09
【问题描述】:

我在 NodeJS 中使用 Python 脚本,如下所示:

const app = express();
const ps = require('python-shell');
var res_json;
var options = {
    mode: 'text',
    pythonPath: '/usr/bin/python',
    scriptPath: './peframe/peframe',
    args: ['--json' ,'/home/mypath/IP.exe']
};
ps.PythonShell.run('peframe.py', options, function (err, results) {
   if (err) throw err;
  console.log('finished');
  res_json=results.join('');
});

但是,如果部署这个应用程序,它找不到 Python(但它在本地工作) 错误是:

Error: spawn /usr/bin/python ENOENT
    at Process.ChildProcess._handle.onexit (child_process.js:232)
    at onErrorNT (internal/child_process.js:407)
    at process._tickCallback (next_tick.js:63)
    at Function.Module.runMain (loader.js:744)
    at startup (internal/bootstrap/node.js:285)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739) 

【问题讨论】:

  • 将代码发布为文本..而不是图像。

标签: python node.js google-app-engine google-cloud-platform


【解决方案1】:

ENOENT 错误表示/usr/bin/python 路径不存在。这是因为您使用的是 NodeJS 运行时——它没有 Python 可用。

如果您确实需要在同一个应用程序中运行 NodeJS 和 Python,您可以将它们作为单独的服务部署在同一个应用程序中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-16
    • 1970-01-01
    • 2018-11-03
    • 1970-01-01
    • 2012-08-31
    相关资源
    最近更新 更多