Relative Package Import

Thomas thomas.bugzilla at gmx.net
Wed Jul 9 16:25:23 CEST 2008


Robert Hancock wrote:
> mypackage/
>           __init__.py
>           push/
>                     __init__.py
>                      dest.py
>          feed/
>                    __init__py
>                     subject.py
> 
> In subject.py I have
>      from ..push import dest

There is no such thing as relative package imports. See 
http://www.python.org/doc/essays/packages.html

Thomas

> 
> But i receive the error:
>   Caught exception importing module subject:
>     File "/usr/local/python/lib/python2.5/site-packages/pychecker/
> checker.py", line 621, in setupMainCode()
>       module = imp.load_module(self.moduleName, file, filename, smt)
>     File "subject.py", line 1, in <module>()
>       from ..feed import dest
>   ValueError: Attempted relative import in non-package
> 
> What am I missing?
> 
> 
> 



More information about the Python-list mailing list