In [1]: import subprocess In [2]: subprocess.check_output(['which', 'python']).decode('ascii') Out[2]: '/usr/bin/python\n'