java jython导入错误

时间:2016-07-10 14:32:34

标签: java jython

我使用jython在java中调用python脚本(使用第3个lib pykriging)。但是我在java控制台中得到了ImportError。我尝试了很多方法,但都没有。 我的代码是这样的:

  public static void main(String[] args) {

    Properties props = new Properties();
    props.put("python.home","D:\\prog\\Python27");
    props.put("python.console.encoding", "UTF-8");
    props.put("python.security.respectJavaAccessibility", "false"); //don't respect java accessibility, so that we can access protected members on subclasses
    props.put("python.import.site","false");
    Properties preprops = System.getProperties();

    PySystemState.initialize(preprops, props, new String[0]);
    PySystemState sys = Py.getSystemState();
    sys.path.append(new PyString("D:\\prog\\Python27"));
    sys.path.append(new PyString("D:\\prog\\Python27\\Lib\\site-packages"));

    PythonInterpreter interp = new PythonInterpreter();
    interp.execfile("pyt/example.py");

}

,错误是这样的: enter image description here

1 个答案:

答案 0 :(得分:1)

也许没有办法解决它,因为' pykriging'取决于&numpy'但这不是在jython中使用numpy的好方法。 Using NumPy and Cpython with Jython