code: def _try_load_module(path, import_name=None):
      logger = logging.getLogger(__name__)
      obj_name = None
      if len(path) > 2 and ':' in path[2:]:
          path, _, obj_name = path.rpartition(":")
      folder, basename = os.path.split(path)
      if folder == '':
          folder = './'
      if basename == '' or not os.path.exists(path):
          raise ArgumentError("Could not find python module to load extension", path=path)
      basename, ext = os.path.splitext(basename)
      if ext not in (".py", ".pyc", ""):
          raise ArgumentError("Attempted to load module is not a python package or module (.py or .pyc)", path=path)
      if import_name is None:
          import_name = basename
      else:
          logger.debug("Importing module as subpackage: %s", import_name)
      try:
          fileobj = None
          fileobj, pathname, description = imp.find_module(basename, [folder])
          if basename in sys.modules:
              mod = sys.modules[basename]
          else:
              mod = imp.load_module(import_name, fileobj, pathname, description)
          if obj_name is not None:
              if obj_name not in mod.__dict__:
                  raise ArgumentError("Cannot find named object '%s' inside module '%s'" % (obj_name, basename), path=path)
              mod = mod.__dict__[obj_name]
          return basename, mod
      finally:
          if fileobj is not None:
              fileobj.close()