title: How to create namespace packages in Python?
body: <p>I have a Python 3 project with the following structure:</p>
  
  <pre><code>project/
  |
  +--root/
     |
     +--__init__.py
     |
     +--sub/
        |
        +--__init__.py
        |
        +--actualcode.py
  </code></pre>
  
  <p>I want to use "namespace packages" so that my lib shares a common namespace with other related libs in separate projects. The import statement should look like this:</p>
  
  <pre><code>from root.sub.actualcode import something
  </code></pre>
  
  <p>The <code>__init__.py</code> file in the root folder contains the following statement to create a namespace package:</p>
  
  <pre><code>from pkgutil import extend_path
  __path__ = extend_path(__path__, __name__)
  </code></pre>
  
  <p>But I cannot reference the code when I import <code>root.sub</code>. It works only when I write:</p>
  
  <pre><code>from sub.actualcode import something # doesn't work with "root.sub..."!
  </code></pre>
  
  <p>What should I do to use <code>root</code> as a namespace?</p>