Sujet : Re: python3 package import difference?
De : cs (at) *nospam* cskk.id.au (Cameron Simpson)
Groupes : comp.lang.pythonDate : 08. Aug 2024, 03:17:56
Autres entêtes
Message-ID : <mailman.34.1723079886.2890.python-list@python.org>
References : 1 2
User-Agent : Mutt/2.2.13 (2024-03-09)
On 07Aug2024 08:35, Tobiah <
toby@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@cskk.id.au>