How to check from python, if an arbitrary program is installed
I guess what I'm looking for is closer to this question.
I'm running a python script (on a windows machine) that requires a program and a service to be installed. Since I have no control over which machines my script will be run on, I need to check from within my script, whether or not the program and service are installed on the machine.
How would I go about doing this?
EDIT: I'm not looking to check if a python module is installed. I know t开发者_如何学运维hat I can do that very easily by just trying to import it. I'm trying to check if a program (say Mozilla Firefox) is installed on the machine
Original answer edited since you clarified your question.
you can use the winreg module to do a check similar to your Java post.
More specifically, you can use the OpenKey method in a try block, catching a WindowsError if the key isn't found.
精彩评论