title: Tried to use relative imports, and broke my import paths?
body: <p>I'm running a Flask server locally on my Mac. </p>
  
  <p><strong>My project:</strong>  </p>
  
  <pre><code>project/my_lib/my_class.py  
  project/testing/flask_server.py  
  project/testing/something/test_class.py  
  </code></pre>
  
  <p>At one point, I tried to get fancy with some relative imports to test a class in a different directory:</p>
  
  <p>In <strong>project/testing/something/test_class.py:</strong></p>
  
  <pre><code>from ..my_lib.my_class import MyClass
  </code></pre>
  
  <p>That gave me an error:</p>
  
  <pre><code>ValueError: Attempted relative import beyond toplevel package
  </code></pre>
  
  <p>So I backed out of that, but now I <strong>can't get my Flask server to run</strong>, even though I eliminated the new import code.</p>
  
  <pre><code>$ python testing/flask_server.py
  </code></pre>
  
  <p>Spits out this:</p>
  
  <pre><code>Traceback (most recent call last):
    File "testing/flask_server.py", line 2, in &lt;module&gt;
      from flask import Flask
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask/__init__.py", line 17, in &lt;module&gt;
      from werkzeug.exceptions import abort
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/werkzeug/__init__.py", line 154, in &lt;module&gt;
      __import__('werkzeug.exceptions')
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/werkzeug/exceptions.py", line 71, in &lt;module&gt;
      from werkzeug.wrappers import Response
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/werkzeug/wrappers.py", line 26, in &lt;module&gt;
      from werkzeug.http import HTTP_STATUS_CODES, \
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/werkzeug/http.py", line 28, in &lt;module&gt;
      from urllib.request import parse_http_list as _parse_list_header
  ImportError: No module named request
  </code></pre>
  
  <p>Huh? </p>
  
  <hr>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>The flask import error only happens in the directory the bad code was originally called from. That is, if I do </p>
  
  <pre><code>from flask import Flask
  </code></pre>
  
  <p>from anywhere in the <strong>project/testing</strong> dir, I get the import error, but if I do it in <strong>project/</strong> or anywhere else on my system, it's fine..?</p>
  
  <hr>
  
  <p><strong>SOLUTION (PARTLY):</strong></p>
  
  <p>I don't have an explanation as to why this happened, but I did the following to fix it:</p>
  
  <ol>
  <li>Created a new <strong>testing/</strong> directory and copied the files from the old one into it. The old <strong>testing/</strong> directory had to be deleted- it was basically corrupted.</li>
  <li>Did my cross-directory imports using absolute instead of relative paths.</li>
  </ol>
  
  <p>(By the way, I tried to retrace my steps to reproduce the relative import error but was unable to, so I'm not sure of either the cause or solution to this whole thing.)</p>