1
私はnpmのpythonshell hereのドキュメントに従おうとしています。私はちょうど成功なしで正しく機能するための簡単な例を得ることを試みています、多くの例はオンラインではありませんが、私はこれに従うことを試みましたone on stackoverflow。では、ここで私のコードに間違いがありますか?なぜ私は下のエラーを得ているのか分かりません。私はPythonではるかに快適です、nodejsは私にとって新しい領域です。何か助けてくれてありがとう。NodejsのPythonShellモジュールを使用
test.pyコード:pythonshellテストと
print("This is a test")
Nodejs:ここ
var PythonShell = require('python-shell');
var options = {
mode: 'text',
pythonPath: '/bin/bash/python2',
pythonOptions: ['-u'],
scriptPath: './TestProject/',
args: ['value1', 'value2', 'value3']
};
PythonShell.run('test.py', options, function (err, results) {
if (err) throw err;
// results is an array consisting of messages collected during execution
console.log('results: %j', results);
});
がある私のエラー
internal/child_process.js:313
throw errnoException(err, 'spawn');
^
Error: spawn ENOTDIR
at exports._errnoException (util.js:1022:11)
at ChildProcess.spawn (internal/child_process.js:313:11)
at exports.spawn (child_process.js:387:9)
at new PythonShell (/home/nomad/TestProject/node_modules/python-shell/index.js:59:25)
at Function.PythonShell.run (/home/nomad/TestProject/node_modules/python-shell/index.js:159:19)
at Object.<anonymous> (/home/nomad/TestProject/app.js:11:13)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
'Error:spawn ENOTDIR'は、Pythonまたはスクリプトパスが見つからないことを示します。 '/ bin/bash/python2'を実行してPythonが実行されているかどうかを調べることができますか?もう一つ、 'scriptPath'の絶対パスを試してください – Bryan
ありがとう、 私は最近distoと私のpythonパスは/ usr/bin/pythonです。しかし、これは私の唯一の問題ではなかった、私はあなたが提案したようにスクリプトが機能するために絶対パスを使う必要があった。 – Machiavelli