python3 package import difference?

Cameron Simpson cs at cskk.id.au
Wed Aug 7 21:17:56 EDT 2024


On 07Aug2024 08:35, Tobiah <toby at tobiah.org> wrote:
>When I do the same import with python3, I get:
>
>    Traceback (most recent call last):
>      File "/home/toby/me", line 1, in <module>
>        import rcs.dbi
>      File "/usr/regos-1.0/lib/python/rcs/dbi/__init__.py", line 1, in <module>
>        from dbi import *
>    ModuleNotFoundError: No module named 'dbi'

Python 3 imports are absolute (they start from the top of the package 
tree and you have no `dbi` at the top). You want a relative import i.e.:

     from .dbi import *

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list