nested absolute_imports python
<p>I am a bit confused on getting imports done properly. I have a project as follows</p>

<pre><code>mainpackge/

    packageone/
    __init__.py
    file.py
    file2.py
    file3.py
    subpackageone/
        __init__.py
        submodule1.py
        submodule2.py

    packagetwo/
    __init__.py
    file.py
    file2.py
    file3.py
    subpackagetwo/
        __init__.py
        submodule1.py
        submodule2.py
</code></pre>

<p>Inside the <code>packageone/subpackage/__init__.py</code> there is an absolute import as follows</p>

<pre><code>from __future__ import absolute_import
from subpackageone.submodule1 import ClassSubmodule1
</code></pre>

<p>Where ClassSubmodule1 is a class that i wish to use inside </p>

<pre><code>packagetwo/subpackagetwo/submodule1.py
</code></pre>

<p>What needs to go inside the <code>packageone/__init__.py</code> file (currently its empty) in order for me to be able to import that class inside <code>packagetwo/subpackagetwo/submodule1.py</code>. Also can someone show how i would import the class (give import code).</p>

<p>Thanks alot!</p>

<p>Figured it out. Basically, the import here:</p>

<pre><code>from __future__ import absolute_import
from subpackageone.submodule1 import ClassSubmodule1
</code></pre>

<p>needs to be moved up to <code>packageone/__init__.py</code>. After i did that i was able to import into packagetwo no problem.</p>

python python-import