简体   繁体   English

java jython导入错误

[英]java jython Import error

I use the jython to call python script (use the 3rd lib pykriging) in java. 我使用jython在Java中调用python脚本(使用第3个库pykriging)。 But I get ImportError in java console. 但是我在java控制台中得到ImportError I had tried many methods but none works. 我尝试了很多方法,但是都没有用。 My code is like this: 我的代码是这样的:

  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");

}

and the error is like this: 错误是这样的: 在此处输入图片说明

Perhaps there is no way to work it,because 'pykriging' depends on 'numpy',but this is no good way to use numpy in jython. 也许没有办法,因为“ pykriging”依赖于“ numpy”,但这不是在jython中使用numpy的好方法。 Using NumPy and Cpython with Jython 在Jython中使用NumPy和Cpython

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM