我正在使用node.js建立一個網站,我試圖執行一個機器學習演算法,但是當我呼叫一個子行程時,我收到了以下資訊:
stderr:<Buffer 6e 74 6f 73 20 70 61 72 61 20 69 6e 73 74 61 6c 61 72 20 6e 61 20 4d 69 63 72 6f 73 6f 66 72
stderr: <緩沖區 6e 74 6f 73 20 70 61 72 61 20 69 6e 73 74 61 6c 61 72 20 6e 61 20 4d 69 63 72 6f 73 6f 66 74 20 53 74 6f 72 65 20 6f 75 20 64 65 73 61 62 69 6c 69 74 ... 88 more bytes>。 子行程以代碼9009退出
這是我的代碼。
這里是我執行檔案的代碼:
router.post('/machineLearning'/span>, 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) => /span> {
console.error('stderr: ', data)
})
childPython.on('close', (code) => {
console.log("child process exited with code "/span>, code)
})
})
這是我要執行的檔案:
這是我要執行的檔案。
import sys
print("Output from Python: Hellow World"/span>)
我的代碼有什么問題?
非常感謝您的關注!
uj5u.com熱心網友回復:
狀態代碼意味著沒有找到檔案。請提供正確的路徑給spawn方法。另外,將緩沖區o/p改為字串,像這樣 :
childPython.stderr. on('data', (data) => {
console.error('stderr: ', data. toString('utf8'))。
})
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/317260.html
標籤:
上一篇:VisualStudio2010專案在使用32位時構建良好,但在嘗試64位時出現LNK2028和LNK2019錯誤。什么可以解決這個問題?
