I have an error "segmentation violation" when I try to execute my code two times and I have no more idea to solve this problem... :/
func (a *MyActivity) Eval(context activity.Context) (done bool, err error) {
pinString := context.GetInput("input1").(string)
// string to int
pinInt, _ := strconv.Atoi(pinString)
//defer python3.Py_Finalize()
python3.Py_Finalize()
python3.Py_Initialize()
if !python3.Py_IsInitialized() {
fmt.Println("Error initializing the python interpreter")
os.Exit(1)
}
dir, err := filepath.Abs(filepath.Dir("./"))
if err != nil {
//log.Fatal(err)
fmt.Println(err)
}
ret := python3.PyRun_SimpleString("import sys\nsys.path.append(\"" + dir + "\")")
if ret != 0 {
//log.Fatalf("error appending '%s' to python sys.path", dir)
fmt.Println("error appending to python sys.path" + dir)
}
// Here is the problem \\
oImport = python3.PyImport_ImportModule("detect") //ret val: new ref
if !(oImport != nil && python3.PyErr_Occurred() == nil) {
python3.PyErr_Print()
//log.Fatal("failed to import module 'detect'")
fmt.Println("failed to import module 'detect'")
}
// Here is the problem \\
.
.
.
.
}
I tried many things but I couldn't solve the problem and it's new for me to use the library go-python3
Thanks a lot for your Help :)