def module_not_found(additional_depth=0):
 tb = sys.exc_info()[2]
 if (len(traceback.extract_tb(tb)) > (1 + additional_depth)):
  return False
 return True

def module_not_found ( additional_depth = 0 ) : tb = sys . exc_info ( ) [ 2 ] if ( len ( traceback . extract_tb ( tb ) ) > ( 1 + additional_depth ) ) : return False return True
checks if importerror was raised because module does not exist or something inside it raised importerror .