I copied and paste the codes from python-shell documentation and have been working on it for the past 2 days, can't seems to get the python-shell to work in electronJS. Unfortunately, I cannot even begin to understand the error message below:
error message
events.js:292 Uncaught Error: spawn ../pyFiles/env/Scripts/python.exe ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267)
at onErrorNT (internal/child_process.js:469)
at processTicksAndRejections (internal/process/task_queues.js:84)
errnoException @ internal/errors.js:514
ChildProcess._handle.onexit @ internal/child_process.js:267
onErrorNT @ internal/child_process.js:469
processTicksAndRejections @ internal/process/task_queues.js:84
app.js
const {PythonShell} = require('python-shell')
let submitBtn = document.querySelector('#submit')
submitBtn.addEventListener("click", (e) => {
e.preventDefault();
let options = {
mode: 'text',
pythonPath: '../pyFiles/env/Scripts/python.exe',
pythonOptions: ['-u'], // get print results in real-time
scriptPath: '../pyFiles',
args: ['World']
};
PythonShell.run('hello.py', options, function (err, results) {
if (err) throw err;
console.log('results: %j', results)
console.log('Finished')
})
console.log('Hello from Javascript1');
});
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Payroll Report Generator</title>
</head>
<body>
<div class="container">
<h1>Payroll Report</h1>
<p>Generate ProSoft Uploadable Excel File with a click!</p>
<form>
<button id="submit" class="btn btn-primary">Convert Now!</div>
</form>
<script src="./app.js"></script>
</body>
</html>