title: Dynamic class loading in Python 2.6: RuntimeWarning: Parent module 'plugins' not found while handling absolute import
body: <p>I am working on a plugin system where plugin modules are loaded like this: </p>
  
  <pre><code>def load_plugins():
     plugins=glob.glob("plugins/*.py")
     instances=[]
     for p in plugins:
        try:
           name=p.split("/")[-1]
           name=name.split(".py")[0]
           log.debug("Possible plugin: %s", name)
           f, file, desc=imp.find_module(name, ["plugins"])
           plugin=imp.load_module('plugins.'+name, f, file, desc)
           getattr(plugin, "__init__")(log)
           instances=instances+plugin.get_instances()
        except Exception as e:
           log.info("Failed to load plugin: "+str(p))
           log.info("Error: %s " % (e))
           log.info(traceback.format_exc(e))
     return instances
  </code></pre>
  
  <p>The code works, but for each import statement in the plugin code i get a warning like this: </p>
  
  <pre><code>plugins/plugin.py:2: RuntimeWarning: Parent module 'plugins' not found while handling absolute import
    import os
  </code></pre>
  
  <p>No errors are reported for the main program code, and the plugins work.</p>
  
  <p>Can somebody explain what the warning means and what I doing wrong. Do I need to create an empty plugins module separately and import it to keep python happy?</p>