jython java Python解释器

时间:2018-12-14 10:52:47

标签: java python jython pythoninterpreter

我需要在Java中运行python脚本(使用jython独立jar),但是当我运行脚本时,出现此错误:

导入错误:没有名为pytesseract的模块

如何导入python库,以运行此脚本?

public class SimpleEmbedded {
public static void main(String []args){

  PythonInterpreter interp = new PythonInterpreter();
  System.out.println("Hello, world from Java");
  interp.execfile("text_rec.py");
  System.out.println("Goodbye ");
  }
}

我还添加了这段代码:

interp = new PythonInterpreter(null, new PySystemState());
PySystemState sys = Py.getSystemState();
sys.path.append(new PyString(rootPath));
sys.path.append(new PyString(modulesDir));

rootPath ModulesDir 是什么?

你能帮我吗?

0 个答案:

没有答案