hmenyus / node-calls-python

Call Python from NodeJS directly in-process without spawning processes
MIT License
252 stars 26 forks source link

Unable to import python file #50

Closed abhinay-podugu closed 1 year ago

abhinay-podugu commented 1 year ago

Iam using node version 18.16. My python version is 3.10. These are the logs related to ncp when i used NODECALLSPYTHON_DEBUGas an environment variable.

Loading python from /usr/lib/python3.10/config-3.10-x86_64-linux-gnu
Running fixlink on /usr/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.so

I was trying to import a python file and the ncp module repeatedly throwed an error saying list index out of range.

code snippet used to import the python file :

const nodecallspython = require("node-calls-python");
const pythonPy = nodecallspython.interpreter;
const filePath = path.join(__dirname, "./sample.py");
await pythonPy.import(filePath).then(async function (pymodule) {
      try {
          await pythonPy.call(pymodule, "myfunc", args);
     }
      catch (err) {
          console.log(err);
      }
});
hmenyus commented 1 year ago

This looks like a regular python error : "list index out of range". please check your code in sample.py and the provided arguments in args.