I cannot import modules from a subfolder,where from a subfolder that I am in it;
the folders that I work with, is like this:
Project
__init__.py
/objects
__init__.py
button.py
text.py
/menu
__init__.py
main_screen.py
I put the __init__.py
file in all of the the folders that containt modules; also using the sys.path.insert
does not gonna work and I don’t know how to handle the problem
I want import button.py
and text.py
modules from objects folder, while I am in main_screen.py
in menu subfolder.
but when I try this in main_screen.py
:
from ..objects.button import Button
from ..objects.text import Text
this error occured:
ImportError: attempted relative import with no known parent package
Amirali Toori is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.