setting sys.path to have the parent module path doesn't import the sub module
Question: The project is in Python3:

    
    
    Project
    |
      Mymodule
      __init__.py
      |  
       submodule1
       __init__.py
       some_script.py
      |
       submodule2
       __init__.py
       myclass.py -> implements MyCLass
    

Whenever I run a script, I start from my Project directory. I always execute
from this Project location

In `Mymodule.submodule1.some_script.py`, I want to import `MyClass` inside
`some_script.py` which is located in `submodule2`

## Things that work in `some_script.py`

    
    
    from ..submodule2.myclass import MyClass
    from Mymodule.submodule2.myclass import MyClass
    

What I am trying to achieve is to avoid location based relative reference in
my script file in my submodules. When ever I try to import a module It should
search in the current directory, if not found, the go to `sys.path`.

So my solution is in `my __init__.py` of my `submodule1`

    
    
    import os
    import sys
    sys.path.append(os.path.abspath('./Mymodule')) -> cwd will be "Project"
    

Now inside my `some_script.py` if I import

    
    
    from submodule2.myclass import MyClass
    

This should work, because I have a sys.path entry to the root/parent
module(Mymodule). I have verified this by print(sys.path) in `some_script.py`

This always throws an error:

`ImportError: No module named 'submodule2.myclass`

Why its not considering the `sys.path` to search for the module.


Answer: I was able to figure out the issue. In my sys.path, there was already a
similarly named module(submodule2) in a different path way ahead of my current
project path. So python was searching file in the first module that it
encountered while searching for the module, which was in a different location

print(sys.path)

\somepath: ... : .... : ... :\myproject_path

\somepath -> has module(submodule2) with a similar name

\myproject_path -> has my module with a similar name submodule2

