title: Relative import beyond top-level package
body: <p>After many searches and attempts I have not found a solution to this problem...</p>
  <p>I am using Sphinx to generate documentation for a Python package.
  You can see the code here: <a href="https://github.com/jajimer/energym/tree/documentation" rel="nofollow noreferrer">https://github.com/jajimer/energym/tree/documentation</a>. The part of the package we are interested in is organized as follows:</p>
  <p><a href="https://i.stack.imgur.com/lsKPu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lsKPu.png" alt="Folder structure" /></a></p>
  <p>In <code>energym/docs/source/conf.py</code> I have configured the path as follows:</p>
  <pre><code>import os
  import sys
  
  sys.path.insert(0, os.path.abspath('../../energym/'))
  </code></pre>
  <p>And now I'm trying to add to the API documentation (<code>energym/doc/source/pages/API-reference.rst</code>) the description of this <code>utils</code> module and all its components. For this, I am using Sphinx's <code>autosummary</code>:</p>
  <pre><code>.. autosummary::
     :toctree: modules
     :template: custom-module-template.rst
     :recursive:
     
     utils
  </code></pre>
  <p>So, after doing <code>make clean &amp;&amp; make html</code>, the documentation for <code>utils.common</code>, <code>utils.rewards</code> and <code>utils.rewards</code> is perfectly created, but not for <code>utils.controllers</code>. According to Sphinx, the following exception occurs:</p>
  <pre><code>File &quot;/home/user/projects/energym/energym/utils/controllers.py&quot;, line 8, in &lt;module&gt;
      from ..utils.common import parse_variables
  ValueError: attempted relative import beyond top-level package
  </code></pre>
  <p>And here is my question. How can I fix it? Is it a relative path problem? I've seen that the problem is due to the following import:</p>
  <pre><code>from ..utils.common import parse_variables
  </code></pre>
  <p>But I don't really know the reason, as the path seems to be perfectly set.</p>