ljc
ljc

Reputation: 938

Find path of linux system binary from within python

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!

Upvotes: 2

Views: 575

Answers (1)

pavdmyt
pavdmyt

Reputation: 46

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

Upvotes: 3

Related Questions