I'm trying to do a relative import. From my understanding, I should have an __init__.py file to suggest this is a module.
Let's say I have:
$ ls
__init__.py foo.py bar.py
__init__.py is an empty file. Additionally:
$ cat foo.py
from .bar import MyExampleClass
thing = MyExampleClass()
and
$ cat bar.py
class MyExampleClass():
pass
So, why do I get?
ImportError: attempted relative import with no known parent package
Your directory which contains all this file will be considered as a package and now you can update code in foo.py:
to
Other thing should work as expected