stocky-lion-56153
07/11/2020, 12:43 PMfrom . import s3
in __main___.py
I get an error
ImportError: attempted relative import with no known parent package
better-actor-92669
07/11/2020, 3:02 PMfrom s3 import ...
stocky-lion-56153
07/11/2020, 4:36 PMmain:
dir when it runs then?better-actor-92669
07/11/2020, 5:15 PMstorage
and put your s3 file there. In this case, your imports will be from storage.s3 import smth
or import storage.s3
stocky-lion-56153
07/11/2020, 5:30 PMpython -m infra
but it runs like python infra
. The former allows relative top-level imports but the latter does not.
❯ tree modplay
modplay
├── __init__.py
├── __main__.py
├── bar
│ ├── __init__.py
│ └── baz.py
└── foo.py
❯ cat modplay/__main__.py
from .bar import baz
from . import foo
foo.foo()
baz.baz()
❯ python -m modplay
foo
baz
~/temp via 🐍 v3.8.3 on ☁️ eu-west-1
❯ python modplay
Traceback (most recent call last):
File "/Users/adrian/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/adrian/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "modplay/__main__.py", line 1, in <module>
from .bar import baz
ImportError: attempted relative import with no known parent package