2

Is there a way to find the path to any given system binary from within Python, similar to the bash command which?

I know I could use the subprocess or sh modules, but these either require me to launch a new process or install additional packages.

Is there a simple pythonic way of doing this?

Thanks!

ljc
  • 943
  • 2
  • 10
  • 26
  • 3
    [This](http://stackoverflow.com/questions/5226958/which-equivalent-function-in-python) might be of use – urban Mar 02 '16 at 09:21

1 Answers1

3

Try distutils.spawn.find_executable, it tries to find executable in the directories listed in path.

pavdmyt
  • 46
  • 2