sbinet / go-python

naive go bindings to the CPython2 C-API
Other
1.53k stars 138 forks source link

could not import 'kwargs' #58

Closed zznan0o0 closed 6 years ago

zznan0o0 commented 6 years ago

excuse me I'm run the example of kw-args and modify-values under the tests but error: importing kwargs... 2017/10/14 05:47:31 could not import 'kwargs' exit status 1

the other is the same

i'm ubuntu 16.04, Python 2.7.12, go 1.6

jjjachyty commented 6 years ago

add this code before your fmt.Printf("importing kwargs...\n")

python.PyRun_SimpleString("import sys")
    python.PyRun_SimpleString("sys.path.append('/DATA/Work/CODE/GO/GOPATH/src/github.com/sbinet/go-python/tests/kw-args')")
danielcooperxyz commented 6 years ago

You could also do something like this

d, _ := os.Getwd()

python.PyRun_SimpleString("import sys")
python.PyRun_SimpleString(
    fmt.Sprintf("sys.path.append('%v')", workingDir))

Does anyone know why this does not happen in the Initalize() function?

sbinet commented 6 years ago

adding it from the go-python.Initialize function would be a bit unpolite.

another simple way is to add . (or any other directory) to $PYTHONPATH.