Python3 : import

Andrew Z formisc at gmail.com
Fri Jul 7 16:37:51 EDT 2017


On Friday, July 7, 2017 at 4:16:38 PM UTC-4, Ian wrote:
> On Fri, Jul 7, 2017 at 2:00 PM, Andrew Z <XXX at gmail.com> wrote:
> > [az at hp tst1]$ python3 ./uno.py
> > Traceback (most recent call last):
> >   File "./uno.py", line 1, in <module>
> >     from . import db
> > SystemError: Parent module '' not loaded, cannot perform relative import
> 
> That error message is a bit confusing, but relative imports are
> relative to packages, not directories. If the module is not part of a
> package then it can't do a relative import. You can use an absolute
> import, though:
> 
> import db

Thank you Ian. that's right on the money. All works now.
I was missing the " ..relative imports are relative to packages, not directories. If the module is not part of a package then it can't do a relative import."
thank you!




More information about the Python-list mailing list