Because import mypkg.mymod initialises it but --hidden-import=mypkg.mymod
just says include it. Python doesn’t automatically import modules just
because they exist otherwise it would be incredibly slow.
If you really don’t want to use from . import mymod then you can put the
following in your __init__.py (note Python>=3.6 only) but it’s terrible
programming practice.
def __getattr__(submodule):
import importlib
try:
return importlib.import_module("mypkg." + submodule)
except ImportError:
raise AttributeError(submodule)
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyinstaller/29594303-d2ed-4d7e-82d4-c21a9170dec4n%40googlegroups.com.