Is there a Python equivalent to the ‘which’ command [duplicate]
Python 3.3 added shutil.which() to provide a cross-platform means of discovering executables: http://docs.python.org/3.3/library/shutil.html#shutil.which Return the path to an executable which would be run if the given cmd was called. If no cmd would be called, return None. Sample calls: >>> shutil.which(“python”) ‘/usr/local/bin/python’ >>> shutil.which(“python”) ‘C:\\Python33\\python.EXE’ Unfortunately, this has not been backported to 2.7.x.