如何从Java检查Windows是否已安装python? [英] How to check if python is installed in windows from java?

查看:121
本文介绍了如何从Java检查Windows是否已安装python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何从Java程序内部检查python是否安装在Windows中? Python不会将其路径添加到系统路径,并且不对可能的安装路径做任何假设(即,可以将其安装在任何位置).

How can I check from inside a java program if python is installed in windows? Python does not add its path to the system Path and no assumption is to be made about the probable path of installation(i.e it can be installed anywhere).

推荐答案

使用Java运行时执行以下命令"python --version".

Use the Java Runtime to exec the following command "python --version".

如果可以使用,则说明您拥有Python,并且标准输出是版本号.

If it works, you have Python, and the standard output is the version number.

如果它不起作用,则说明您没有Python.

If it doesn't work, you don't have Python.

这篇关于如何从Java检查Windows是否已安装python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆