title: Wierd attribute error with importing into directories
body: <p>I have a directory tree as follows:</p>
  <pre><code>main.py
  dir1
    sub1.py
    sub2.py
  </code></pre>
  <p>In <code>main.py</code>:</p>
  <pre class="lang-py prettyprint-override"><code>import dir1.sub1
  
  </code></pre>
  <p>In <code>dir1/sub1.py</code>:</p>
  <pre class="lang-py prettyprint-override"><code>def f1() -&gt; None:
      print(&quot;f1&quot;)
  
  
  import dir1.sub2
  
  dir1.sub2.f2()
  
  </code></pre>
  <p>In <code>dir1/sub2.py</code>:</p>
  <pre class="lang-py prettyprint-override"><code>import dir1.sub1
  
  
  def f2() -&gt; None:
      dir1.sub1.f1()
      print(&quot;f2&quot;)
  
  </code></pre>
  <p>When I run <code>main.py</code>, I get the following error message:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;...\main.py&quot;, line 1, in &lt;module&gt;
      import dir1.sub1
    File &quot;...\dir1\sub1.py&quot;, line 7, in &lt;module&gt;
      dir1.sub2.f2()
    File &quot;...\dir1\sub2.py&quot;, line 5, in f2
      dir1.sub1.f1()
  AttributeError: module 'dir1' has no attribute 'sub1'. Did you mean: 'sub2'?
  </code></pre>
  <p>(Where the <code>...</code> at the beginning of the file path is my working directory.)</p>
  <p>If I change <code>main.py</code> to</p>
  <pre class="lang-py prettyprint-override"><code>import dir1.sub2
  
  </code></pre>
  <p>I get a slightly different error message:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;...\main.py&quot;, line 1, in &lt;module&gt;
      import dir1.sub2
    File &quot;...\dir1\sub2.py&quot;, line 1, in &lt;module&gt;
      import dir1.sub1
    File &quot;...\dir1\sub1.py&quot;, line 7, in &lt;module&gt;
      dir1.sub2.f2()
  AttributeError: module 'dir1' has no attribute 'sub2'
  </code></pre>
  <p>If I move <code>sub1.py</code> and <code>sub2.py</code> to the same directory as <code>main.py</code> and re‐direct imports as necessary, I get the expected output of</p>
  <pre><code>f1
  f2
  </code></pre>
  <p>Why does this happen, and how can I make it not happen?</p>