[英]Spring boot app with Jython on raspberry pi
我正在尝试在树莓派上的 Spring 引导项目中使用 jython。 我有一个问题,因为当我在 windows 上运行它时它可以工作,但在树莓派(系统树莓派)上不起作用。 它在新的 PythonInterpreter() 上崩溃了。
代码:
try {
PythonInterpreter pyInterp = new PythonInterpreter();
pyInterp.exec("print('Hello Python World!')");
} catch (Exception e) {
e.printStackTrace();
}
错误:
ImportError: Cannot import site module and its dependencies: No module named site 确定以下属性是否正确:
您可以使用 -S 选项或 python.import.site=false 不导入站点模块
好的,我解决了这个问题。 我必须启动该属性和 props.put("python.import.site", "false"); 运行参数很重要。
try {
Properties props = new Properties();
props.put("python.home", "/home/pi/Dysk/jython-standalone-2.7.1.jar");
props.put("python.console.encoding", "UTF-8");
props.put("python.security.respectJavaAccessibility", "false");
props.put("python.import.site", "false");
Properties preprops = System.getProperties();
PythonInterpreter.initialize(preprops, props, new String[0]);
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.exec("print('Hello Python World!')");
} catch (Exception e) {
e.printStackTrace();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.