[英]java jython Import error
我使用jython在Java中调用python脚本(使用第3个库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");
}
也许没有办法,因为“ pykriging”依赖于“ numpy”,但这不是在jython中使用numpy的好方法。 在Jython中使用NumPy和Cpython
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.