我一直在尝试按照此处的 npm pythonshell 文档进行操作。我只是想找一个简单的例子来正确运行但没有成功,网上的例子不多,但我确实尝试在 stackoverflow 上遵循这个例子。那么我的代码到底有什么问题呢?我不确定为什么会收到以下错误。我在 python 中更自在,nodejs 对我来说是一个新领域。感谢您的任何帮助。
test.py 代码:
print("This is a test")
Run Code Online (Sandbox Code Playgroud)
带有pythonshell测试的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);
});
Run Code Online (Sandbox Code Playgroud)
这是我的错误
internal/child_process.js:313
throw errnoException(err, 'spawn');
^
Error: spawn ENOTDIR
at exports._errnoException (util.js:1022:11)
at ChildProcess.spawn …Run Code Online (Sandbox Code Playgroud)