[Tutor] Is an executable available?

Kent Johnson kent37 at tds.net
Mon Feb 14 13:14:47 CET 2005


Stuart Murdock wrote:
> Hi
> 
> I am working from within python and want to know the best way to know if 
> a certain package is installed for use on my machine.
> 
> I want to know from within python that a specific executable file is on 
> my path where I could actually run the command from a prompt in a system 
> shell.

Look at the function _iscommand() in the webbrowser module, I think it does exactly what you want - 
it searches the PATH for the file you give it, e.g.
  >>> webbrowser._iscommand('python.exe')
True

Kent



More information about the Tutor mailing list