1.Cannot run program "python": CreateProcess error=2, 系统找不到指定的文件
Run --》Run Configurations... --》 -Environment --》 New,--》Name设置为:PATH,--》Value设置为:python的安装路径E:\soft\Miniconda3
2.样例代码
public static void learn() {
try {
String[] args = new String[] { "python", "E:\\code\\python\\tensorflow\\testInter2.py" };
Process proc = Runtime.getRuntime().exec(args);// 执行py文件
BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
proc.waitFor();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}