我正在使用node.js构建一个网站,并试图执行一个机器学习算法,但当我调用子进程时,我收到了以下消息:
stderr:子进程退出,代码为9009
下面是我执行该文件的代码:
router.post('/machineLearning', function (req, res) {
var childPython = spawn('python', ['../machineLearning/ml_teste.py'])
childPython.stdout.on('data', function (data) {
console.log("It worked")
})
childPython.stderr.on('data', (data) => {
console.error('stderr: ', data)
})
childPython.on('close', (code) => {
console.log("child process exited with code ", code)
})
})
下面是我正在尝试执行的文件:
import sys
print("Output from Python: Hellow World")
我的代码出了什么问题?
非常感谢您的关注!
发布于 2021-01-18 01:39:18
状态码表示找不到文件。请提供派生方法的正确路径。另外,将缓冲区o/p更改为字符串,如下所示:
childPython.stderr.on('data', (data) => {
console.error('stderr: ', data.toString('utf8'));
})
https://stackoverflow.com/questions/65763654
复制相似问题