java - Why does Jython not find this module? -


possible duplicate:
how run python script java?

i running python script using jython , got error:

exception in thread "main" traceback (innermost last): file "c:\facebook\loginpython\facebook.py", line 5, in ? importerror: no module named cookielib

why doesn't work?

a little bit more using jython - had share of problems well. note may not best way it, works fine me.

i assume want call function foo in module bar java code takes string argument , returns string:

    pythoninterpreter interpreter = new pythoninterpreter();     // append directory containing module python search path , import     interpreter.exec("import sys\n" + "sys.path.append(pathtomodule)\n" +      "from bar import foo");     pyobject meth = interpreter.get("foo");     pyobject result = meth.__call__(new pystring("test!"));     string real_result = (string) result.__tojava__(string.class); 

the sys.path.append() part necessary if module isn't part of python search path default, may problem if import or module not find errors. need cast objects between java , python versions, you'll need if necessary, far needed primitive types easy cast, not sure if it's easy arbitrary java objects.


Comments

Popular posts from this blog

jQuery clickable div with working mailto link inside -

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -