title: What 'Attempted relative import beyond top-level package' error means in Python?
body: <p>I'm using python 3.7 and ran into a relative import error "Attempted relative import beyond top-level package" with the following folder structure:</p>
  
  <pre><code>├── app
  │   ├── __init__.py
  │   ├── services
  │   │   └── item_service.py
  │   └── views
  │       ├── home.py
  │       ├── __init__.py
  </code></pre>
  
  <p><strong>My goal:</strong> import variable <em>foo</em> from the top level <em>_init_.py</em> to <em>item_service.py</em> using </p>
  
  <pre><code>from .. import foo
  </code></pre>
  
  <p>Pylint gives the error when trying this.</p>
  
  <p>However the same exact import statement works in <em>home.py</em>, and if I add a empty <em>_init_.py</em> file to the services folder, the import works.</p>
  
  <p>So my my question is, why? Does python require your module to be in a subpackage in order to relatively import parent package's contents?</p>