Plugin system, RuntimeWarning: Parent module 'ext_abc' not found while handling absolute import

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Jan 25 22:49:25 EST 2009


En Sun, 25 Jan 2009 04:55:47 -0200, Torsten Mohr <tmohr at s.netic.de>  
escribió:

> i try to write a plugin system that i want to use to let users extend
> a module that i write.
>
> Within the module there is an extension loader that loads an extension
> module.  This extension module should be able to import modules from
> my system, which provides some extensions.
>
> Basically, this here works but gives a warning:
> RuntimeWarning: Parent module 'ext_abc' not found while handling  
> absolute import


> here = os.path.abspath('.')

(Unrelated to the main question, but you probably want to use  
os.path.dirname(os.path.abspath(__file__)) instead - the above just  
returns the current directory, which might not be the directory containing  
the module)

> mpath = os.path.abspath('mymodule')
> epath = os.path.abspath('extension')
>
> sys.path.append(here)
> sys.path.append(mpath)
>
> FILE mymodule/__init__.py:

So mymodule is actually a package. Packages should *not* appear in  
sys.path.

-- 
Gabriel Genellina




More information about the Python-list mailing list