Have to create __init__.py
file inside the test dir:
Because The __init__.py
files are required to make Python treat the directories as containing packages.
parent/
child1/
__init__.py
file1.py
child2/
__init__.py
file2.py
From the error:
If run the child2/file2.py
file directly. You are not able to access child1/file1.py
from the child2/file2.py
Because only from the parent directory can access the child.
If have a folder structure like:
parent/
child1/
__init__.py
file1.py
child2/
__init__.py
file2.py
file3.py
If we run the file3.py
file. Can able to access both child1/file1.py
, child2/file2.py
in file3.py
Because It is running from the parent directory.
If we need to access child1/file1
from child2/file2.py
, We need to set the parent directory:
By running this below command we can achieve it...
PYTHONPATH=. python child2/file2.py
PYTHONPATH=.
It refers the parent path. Then runs child2/file2.py
file from the shell