hmenyus / node-calls-python

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

`Segmentation fault` when node import python module #56

Closed l20 closed 1 year ago

l20 commented 1 year ago

System: WSL2 Ubuntu-22.4 LTS CPU: x86_64 npm: v6.14.12 node: v12.22.1 node-gyp: v9.0.0 Python: v3.10.6 node-calls-python: v1.7.7

example:

# test.py
import numpy as np

def multiple(a, b):
    return np.multiply(a, b).tolist()
// test.js
const nodecallspython = require("node-calls-python")

const py = nodecallspython.interpreter

py.import("./test.py").then(async function(pymodule) {
    // const result = await py.call(pymodule, "multiple", [1, 2, 3, 4], [2, 3, 4, 5])
    // console.log(pymodule)
});

When I execute node test.js on terminal, Output Segmentation fault

toncho11 commented 1 year ago

Try full path for py.import("./test.py") and do not use Python virtual environments.

hmenyus commented 1 year ago

Cannot reproduce