I have a package that contains a module with compatible imports. However, I cannot import from the exposed modules directly; I have to use slightly more inconvenient workarounds.
Inside common/compat.py, I have this:
import bcrypt
In main.py, this does not work:
from common.compat.bcrypt import hashpw
with the error:
Traceback (most recent call last):
File "main.py", line 2, in <module>
from common.compat.bcrypt import hashpw
ImportError: No module named bcrypt
However, this works fine:
from common.compat import bcrypt
# now bcrypt.hashpw works fine
Is there any way to make the first one work properly without having to do the second solution? I would prefer from imports for quite a few classes and methods.