tags:

views:

406

answers:

5

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).

+1  A: 

Have you tried querying the registry to check if it is installed? It is stored in

software\python\pythoncore

If the user has a (relatively) new version of python, that is installed with the MSI-package, you can use the MsiEnumProducts Function to check if python is installed.

Espo
Ya thats one way. But will the registry be upto date?
Goutham
IIRC, Python can be installed in a "no registry updates" mode.
S.Lott
+1  A: 

Most Python installers add keys to the Windows registry. Here's an article about how to add that information, you can use it to see how to read the information.

Ned Batchelder
A: 

exec(String command) Executes the specified string command in a separate process. Check for Python from command

Webbisshh
The OP states that "Python does not add its path to the system Path", so how would this work?
Espo
hey noo,it must be on PATH in windows atleast!
Webbisshh
A: 

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

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

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

S.Lott
The OP states that "Python does not add its path to the system Path", so how would this work?
Espo
If you can't execute `python`, then it isn't really "installed" is it?
S.Lott
A: 

to everyone else: Python can be installed without modifying the paths, and then you have to run it with a fully qualified path name.

Blade