2016-07-10 5 views
0

Ich benutze das jython, um Python-Skript (verwenden Sie die 3. lib pykriging) in Java. Aber ich bekomme ImportError in der Java-Konsole. Ich habe viele Methoden ausprobiert, aber keine funktioniert. Mein Code ist wie folgt:java jython Importfehler

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

} 

und der Fehler ist wie folgt: enter image description here

Antwort

1

Vielleicht gibt es keine Möglichkeit, es zu arbeiten, denn ‚pykriging‘ hängt von ‚numpy‘, aber das ist kein gute Möglichkeit, in jython numpy zu verwenden. Using NumPy and Cpython with Jython

+1

Überlegen Sie nicht, Ihre eigene Antwort nach nur 10 Minuten zu schreiben; Aktualisiere stattdessen deine Frage. – GhostCat