I have a python package directory like this:
proj/
  mod_a/
    __init__.py
    x.py
    submod_x/
      __init__.py
      y.py
  mod_b/
    __init__.py
    z.py
with x.py:
import submod_x.y
z.py:
import sys, os.path
sys.path.append(os.path.abspath('../'))
import mod_a.x
Now when I run:
$ python2 z.py
I get the things done coded in y.py
But when I run:
$ python3 z.py
I got an exception:
Traceback (most recent call last):
File "z.py", line 4, in <module>
  import mod_a.x
File ".../proj/mod_a/x.py", line 1, in <module>
  import submod_x.y
ImportError: No module named 'submod_x'
I wonder what differences between Python 2 and Python 3 when importing a package, and how can I import a package located in its parent directory using absolute import in Python 3?
 
     
     
    