# Python program to explain shutil.which() method # check if python is in PATH # importing os module import os # importing shutil module import shutil # cmd cmd = 'python' # Using shutil.which() method locate = shutil.which(cmd) # Print result print(locate) # outputs: /usr/bin/python