title: Python: Importing a file from a parent folder
body: <p>...Now I know this question has been asked many times &amp; I have looked at these other threads. Nothing so far has worked, from using <code>sys.path.append('.')</code> to just import <code>foo</code>.</p>
  <p>I have a python file that wishes to import a file (that is in its parent directory). Can you help me figure out how my child file can successfully import its a file in its parent directory. I am using python 2.7.</p>
  <p>The structure is like so (each directory also has the <code>__init__.py</code> file in it):</p>
  <pre><code>StockTracker/  
  └─ Comp/  
     ├─ a.py  
     └─ SubComp/  
        └─ b.py
  </code></pre>
  <p>Inside b.py, I would like to import <code>a.py</code>: So I have tried each of the following but I still get an error inside <code>b.py</code> saying <code>&quot;There is no such module a&quot;</code>.</p>
  <pre class="lang-py prettyprint-override"><code>import a
  
  import .a
  
  import Comp.a
  
  import StockTracker.Comp.a
  
  import os
  import sys
  sys.path.append('.')
  import a    
  sys.path.remove('.')
  </code></pre>