If you are going to call relative.py
directly and i.e. if you really want to import from a top level module you have to explicitly add it to the sys.path
list.
Here is how it should work:
# Add this line to the beginning of relative.py file
import sys
sys.path.append('..')
# Now you can do imports from one directory top cause it is in the sys.path
import parent
# And even like this:
from parent import Parent
If you think the above can cause some kind of inconsistency you can use this instead:
sys.path.append(sys.path[0] + "/..")
sys.path[0]
refers to the path that the entry point was ran from.