title: Relative imports for the billionth time
body: <p>I've been here:</p>
  <ul>
  <li><a href="http://www.python.org/dev/peps/pep-0328/" rel="noreferrer">http://www.python.org/dev/peps/pep-0328/</a></li>
  <li><a href="http://docs.python.org/2/tutorial/modules.html#packages" rel="noreferrer">http://docs.python.org/2/tutorial/modules.html#packages</a></li>
  <li><a href="https://stackoverflow.com/questions/10059002/python-packages-relative-imports">Python packages: relative imports</a></li>
  <li><a href="https://stackoverflow.com/questions/9123062/python-relative-import-example-code-does-not-work">python relative import example code does not work</a></li>
  <li><a href="https://stackoverflow.com/questions/8299270/ultimate-answer-to-relative-python-imports">Relative imports in python 2.5</a></li>
  <li><a href="https://stackoverflow.com/questions/4175534/relative-imports-in-python">Relative imports in Python</a></li>
  <li><a href="https://stackoverflow.com/questions/13233931/python-disabling-relative-import?rq=1">Python: Disabling relative import</a></li>
  </ul>
  <p>and plenty of URLs that I did not copy, some on SO, some on other sites, back when I thought I'd have the solution quickly.</p>
  <p>The forever-recurring question is this: how do I solve this &quot;Attempted relative import in non-package&quot; message?</p>
  <pre><code>ImportError: attempted relative import with no known parent package
  </code></pre>
  <p>I built an exact replica of the package on pep-0328:</p>
  <pre><code>package/
      __init__.py
      subpackage1/
          __init__.py
          moduleX.py
          moduleY.py
      subpackage2/
          __init__.py
          moduleZ.py
      moduleA.py
  </code></pre>
  <p>The imports were done from the console.</p>
  <p>I did make functions named spam and eggs in their appropriate modules.  Naturally, it didn't work.  The answer is apparently in the 4th URL I listed, but it's all alumni to me. There was this response on one of the URLs I visited:</p>
  <blockquote>
  <p>Relative imports use a module's name attribute to determine that module's position in the package hierarchy. If the module's name does not contain any package information (e.g. it is set to 'main') then relative imports are resolved as if the module were a top level module, regardless of where the module is actually located on the file system.</p>
  </blockquote>
  <p>The above response looks promising, but it's all hieroglyphs to me.  So my question, how do I make Python not return to me &quot;Attempted relative import in non-package&quot;? has an answer that involves -m, supposedly.</p>
  <p>Can somebody please tell me why Python gives that error message, what it means by &quot;non-package&quot;, why and how do you define a 'package', and <em>the precise answer put in terms easy enough for a kindergartener to understand</em>.</p>