Open camelhehe opened 5 years ago
test.py import numpy import sklearn
def a(): return
main.go t := python.PyImport_ImportModule("test")
t actually is nil
Just remove import numpy and sklearn from test.py, then it works.
you're probably mixing python libraries (i.e.: trying to import numpy
from anaconda while you compiled go-python
against another python2 interpreter.)
try this program to display the error:
package main
import (
"log"
"github.com/sbinet/go-python"
)
func init() {
err := python.Initialize()
if err != nil {
panic(err.Error())
}
}
func main() {
m := python.PyImport_ImportModule("numpy")
if m == nil {
python.PyErr_Print()
log.Fatalf("could not import numpy")
}
m.DecRef()
}
I just found there is no any 3rd packages were imported in your test examples. I tried to import 3rd package, import numpy in a py file, then go run main.go, will report a failed import. Please tell me how to import other 3rd packages installed in anaconda2/lib/python2.7/site-packages/
thanks