code: def _get_module_name_from_fname(fname):
      
      fname = fname.replace(".pyc", ".py")
      for mobj in sys.modules.values():
          if (
              hasattr(mobj, "__file__")
              and mobj.__file__
              and (mobj.__file__.replace(".pyc", ".py") == fname)
          ):
              module_name = mobj.__name__
              return module_name
      raise RuntimeError("Module could not be found")
docs: Get module name from module file name.