Python: Importing a file from a parent folder
<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 sys.path.append('.') to just import foo</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 <strong>__<em>init</em>__</strong>.py file in it):</p>

<blockquote>
  <p>StockTracker/<br>
  <strong>__</strong><em>Comp/<br>
  <strong></em>____</strong><em>a.py<br>
  <strong></em>____</strong><em>SubComp/<br>
  <strong></em>__<em>_</em>__</strong>_b.py</p>
</blockquote>

<p>Inside b.py, I would like to import a.py: So I have tried each of the following but I still get an error inside b.py saying "There is no such module a" </p>

<pre><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>
