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