使用节点js错误号22运行python脚本

时间:2018-05-04 11:10:19

标签: javascript node.js python-3.x express

我使用node.js通过Web浏览器运行python脚本。下面是ScriptRunner.js代码。

var PythonShell = require('python-shell');
var path = require('path');
exports.runScript = function() {
   var options = {
       scriptPath: 'D:\L4Project\working code\finalproject\routes'
   };
PythonShell.run('sensitive2.py',options, function (err, results) {
  if (err) throw err;

  console.log('results: %j', results);
});
}

当我在浏览器中运行脚本时,它会返回如下所示的错误信息。

D:\L4Project\working code\finalproject\routes\scriptRunner.js:10
      if (err) throw err;
               ^

outes\sensitive2.py': [Errno 22] Invalid argumentg codeinalproject at PythonShell.parseError (D:\L4Project\working code\finalproject\node_modules\python-shell\index.js:191:17)
    at terminateIfNeeded (D:\L4Project\working code\finalproject\node_modules\python-shell\index.js:98:28)
    at ChildProcess.<anonymous> (D:\L4Project\working code\finalproject\node_modules\python-shell\index.js:89:9)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)

我有很多googles,没有任何效果。有人可以帮我解决问题吗?

0 个答案:

没有答案