解决方法 需要指定python命令行处理模块的路径
String[] args = new String[] { “/home/learn/anaconda3/bin/python”, file.substring(5,file.length())};
System.out.println(args);
Process pr = Runtime.getRuntime().exec(args);
BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream(),“GB2312”));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
ubuntu中java调用python出现Cannot run program "python": CreateProcess error=2, 系统找不到指定的文件
最新推荐文章于 2025-04-21 08:56:14 发布
本文介绍了一种通过Java调用Python脚本的方法,详细展示了如何设置Python命令行处理模块的路径,并通过代码示例解释了具体实现过程。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Python3.8
Conda
Python
Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本
1274

被折叠的 条评论
为什么被折叠?



