title: How to make absolute imports in python
body: <p>Hey so I know this question has kind of been asked before, but the answers do not work for me so here it goes.</p>
  
  <p>How do you do absolute imports in python?</p>
  
  <p>Ex.</p>
  
  <pre><code>app/
    app.py
    __init__.py
    util/
      __init__.py
      a.py
      b.py
    datastore/
      c.py
      d.py
      __init__.py
  </code></pre>
  
  <p>and then in <code>app.py</code> I want to do this</p>
  
  <p><code>from app.util.a import SomeObject as sobj</code></p>
  
  <p>I tried adding the directory to my PYTHONPATH but it did not work</p>
  
  <p>Ex.</p>
  
  <p><code>export PYTHONPATH=$PYTHONPATH:$(pwd)</code></p>
  
  <p>I need to do this for testing and deploying the application to a server and I dont want to do this:</p>
  
  <p><code>from util.a import SomeObject as sobj</code></p>
  
  <p>is there a way to do absolute imports in the <code>setup.py</code> script or is there a way to do a <code>sys.path.append</code>?</p>
  
  <p>Also is there a tool that will generate this for you because this is kind of frustrating, the python community, including myself should develop a tool to set up proper testing and src directories to make everyones life easier.</p>