0

I use the jython to call python script (use the 3rd lib pykriging) in java. But I get ImportError in java console. 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: enter image description here

1 Answer 1

1

Perhaps there is no way to work it,because 'pykriging' depends on 'numpy',but this is no good way to use numpy in jython. Using NumPy and Cpython with Jython

Sign up to request clarification or add additional context in comments.

1 Comment

Consider not writing your own answer after just 10 minutes; update your question instead.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.