How to deal with python import with custom API
Question: I created an API for my work. (python version 3.4) My API look like this:

  * MyAPI 
    * `__init_.py`
  * Communication 
    * `__init_.py`
    * `SerialCom.py`
  * JsonManager 
    * `__init__.py`
    * `VersionHandler.py`
  * Sessions 
    * `__init__.py`
    * `SessionManager.py`
    * `Session.py`
  * TestAPI 
    * `__init__.py`
    * `mainWindows.py`
    * `mainWindowsQtUi.py`

In my testAPI it work well I have to problem with import importing my API this
way:

    
    
    from Sessions.SessionManager import SessionManager
    

But when I try to import it in another project I got some trouble with import.
I'm using Visual studio with Python plug-in I added my API in the search paths
it look like that:

    
    
    My_api/MyAPI
          /MyAPI_Test
    

so in my code I try this :

    
    
    from My_api.MyAPI.Sessions.SessionManager import SessionManager
    

And I got an `ImportError`. Visual studio show me the `SessionManager` file in
the API and show me this line:

    
    
    from Sessions.Session import Session
    

I'm confused, it works fine with my TestAPI package but fail with an external
package. I guess I missed something but don't know what.


Answer: First of all ensure, that your project directory exists in PYTHONPATH.

If that is not the case, This could occur if you are already importing
`SessionManager` in your Sessions/**init**.py. Then when you try -

    
    
    from Sessions.SessionManager import SessionManager
    

python is trying to import SessionManager from SessionManager class.

