Node.js 节点应用程序的pythonshell
问题: 如何在节点应用程序中运行python脚本 这项工作: 在命令行中,我运行这个程序,它可以正常工作Node.js 节点应用程序的pythonshell,node.js,npmjs,Node.js,Npmjs,问题: 如何在节点应用程序中运行python脚本 这项工作: 在命令行中,我运行这个程序,它可以正常工作 python generatePersonTerraform.py -s http://localhost:8080/api/person/239/exportPersonGeneration 在Node server.js中不起作用的代码 错误: 得到了这个错误: at PythonShell.parseError (/root/my-app/node_modules/pytho
python generatePersonTerraform.py -s http://localhost:8080/api/person/239/exportPersonGeneration
在Node server.js中不起作用的代码
错误:
得到了这个错误:
at PythonShell.parseError (/root/my-app/node_modules/python-shell/index.js:191:17)
at terminateIfNeeded (/root/my-app/node_modules/python-shell/index.js:98:28)
at ChildProcess.<anonymous> (/root/my-app/node_modules/python-shell/index.js:89:9)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:194:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
executable: 'python',
options: null,
script: 'generatePersonTerraform.py',
args:
[ '-s',
'http://localhost:8080/api/person/135/exportPersonGeneration' ],
exitCode: 0 }
但是,它也运行并工作了,它只是暂停了节点应用程序。所以,如果我想办法让它不停下来,那我就没事了。python脚本似乎构建了它应该构建的所有文件。'-s'应该是args,而不是pythonOptions。谢谢,你回答了我的问题,但是你能看看我的编辑吗?
at PythonShell.parseError (/root/my-app/node_modules/python-shell/index.js:191:17)
at terminateIfNeeded (/root/my-app/node_modules/python-shell/index.js:98:28)
at ChildProcess.<anonymous> (/root/my-app/node_modules/python-shell/index.js:89:9)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:194:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
executable: 'python',
options: [ '-s' ],
script: 'generatePersonTerraform.py',
args: [ 'http://localhost:8080/api/person/239/exportPersonGeneration' ],
exitCode: 1 }
var options = {
mode: 'text',
pythonPath: 'python',
pythonOptions: [],
scriptPath: '.',
args: ['-s', 'http://localhost:8080/api/serviceType/135/exportPluginGeneration']
};
at PythonShell.parseError (/root/my-app/node_modules/python-shell/index.js:191:17)
at terminateIfNeeded (/root/my-app/node_modules/python-shell/index.js:98:28)
at ChildProcess.<anonymous> (/root/my-app/node_modules/python-shell/index.js:89:9)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:194:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
executable: 'python',
options: null,
script: 'generatePersonTerraform.py',
args:
[ '-s',
'http://localhost:8080/api/person/135/exportPersonGeneration' ],
exitCode: 0 }