import shutil if shutil.which('ls'): subprocess.call(["ls"])
shutil.which returns the path of the specified command if found, or None if not found.
Recommended Posts