I am trying to run python commmands from nodejs in such a way:
user input: print(69) bot process user input and execute command bot sends results into chat
i have taken this code and modify myself to args.join (' ')
let options = {
mode: 'text',
pythonPath: 'C:/Python39/python.exe',
pythonOptions: ['-u'], // get print results in real-time
args: ['value1', 'value2', 'value3']
};
PythonShell.run(args.join(' '), options, function (err, results) {
if (err) throw err;
// results is an array consisting of messages collected during execution
message.channel.send('results: %j', results);
});
and somehow pythonshell is trying to draw commands from a file other then a argument.
PythonShellError: C:/Python39/python.exe: can't open file 'C:\bot096\memu stable\print(69)': [Errno 2] No such file or directory
at PythonShell.parseError (C:\bot096\memu stable\node_modules\python-shell\index.js:269:21)
at terminateIfNeeded (C:\bot096\memu stable\node_modules\python-shell\index.js:144:32)
at Socket.<anonymous> (C:\bot096\memu stable\node_modules\python-shell\index.js:118:17)
at Socket.emit (node:events:388:22)
at endReadableNT (node:internal/streams/readable:1305:12)
at processTicksAndRejections (node:internal/process/task_queues:80:21) {
executable: 'C:/Python39/python.exe',
options: [ '-u' ],
script: 'print(69)',
args: [ 'value1', 'value2', 'value3' ],
exitCode: 2
}
so i am out of ideas how to actually make it draw from input not from a file??
fetched source:
https://github.com/extrabacon/python-shell
also looked at these
https://www.geeksforgeeks.org/run-python-script-using-pythonshell-from-node-js/
How to call a Python function from Node.js
if im wrong, correct me. Im here to learn