import subprocesstry: ret = subprocess.check_call('NotExistCommand')except: import traceback traceback.print_exc()