SyntaxError when firing python scirpt in nodejs

I'm using python-shell package for nodejs to fire a python script, which return SyntaxError: invalid syntax.

Nodejs code

const options = {
    mode: 'text',
    pythonPath: '/usr/bin/python3',
    scriptPath: __dirname + '/script',
var pyshell = new PythonShell('', options);


pyshell.on('message', function (message) {
  // received a message sent from the Python script (a simple "print" statement)

// end the input stream and allow the process to exit
pyshell.end(function (err,code,signal) {
  if (err) throw err;
  console.log('The exit code was: ' + code);
  console.log('The exit signal was: ' + signal);

Python script



PythonShellError:   File "/app/src/back/script/", line 1
SyntaxError: invalid syntax

If i run the script, with the command : python3 , i'm getting the word 'test' printed as excepeted, but not with the use of python-shell as i want to. My python version is 3.8.10

Read more here:

Content Attribution

This content was originally published by Tollaris at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: