2024-09-24 04:21:34 发布
网友
我试图从java调用python文件。但它抛出了以下错误。在
java.io.IOException: Cannot run program "python": CreateProcess error=2, The system cannot find the file specified
我尝试过的代码是:
有什么问题吗?在
在运行时.exec不包含路径信息的文件应位于用户目录中,而不在指定用作工作目录的目录中。 尝试使用此代码一次。在
Runtime rt = Runtime.getRuntime(); Process prs; File Dir_temp = new File("C:\\Project\\Script\\"); prs = rt.exec(new File(Dir_temp, "Test.py").getAbsolutePath(), null, Dir_temp); prs.waitFor(); prs.destroy();
在运行时.exec不包含路径信息的文件应位于用户目录中,而不在指定用作工作目录的目录中。 尝试使用此代码一次。在
相关问题 更多 >
编程相关推荐