1,本地调用无第三方包
runtime
Process pr = Runtime.getRuntime().exec("C:\\ProgramData\\Anaconda3\\python.exe untitled0.py");
BufferedReader in = new BufferedReader(new
InputStreamReader(pr.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
pr.waitFor();
jython:
public static void main(String args[]) throws IOException {
PythonInterpreter interpreter = new PythonInterpreter();
System.setproperty("pythone.home","c:\\jython2.7.0");
InputStream filepy = new FileInputStream("E:\\test.py");
interpreter.execfile(filepy);
filepy.close();
}
2,问题
在python文件中有第三方包,会出现importError,暂时无解决,解决办法网上不实,或者自己没有理解透彻,待改进