Properties props = new Properties(); props.put("python.home", "path to the Lib folder"); 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.execfile("C:/Python27/asdd.py");
分界线以上 解决调用python出现的Cannot import site module and its dependencies: No module named site问题
以下 正常调用方法