Python3 : import

Ian Kelly ian.g.kelly at gmail.com
Fri Jul 7 16:15:36 EDT 2017


On Fri, Jul 7, 2017 at 2:00 PM, Andrew Z <formisc 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



More information about the Python-list mailing list