title: Python Sphinx Autosummary: failed to import module
body: <p>I am trying to create autosummary using sphinx-autosummary for my python code which looks like as follows:</p>
  
  <pre><code>main
  ├───modA
  |   ├───__init__.py
  |   ├───modA.py
  ├───modB
  |   ├───__init__.py
  |   ├───modB.py
  ├───docs
  |   ├───build
  |   └───source
  |       ├───refs
  |       |   |───_autosummary
  |       |   |───index.rst
  |       |   |───modA.rst
  |       |   |───modB.rst
  |       ├───index.rst
  |       ├───conf.py
  </code></pre>
  
  <p>As mentioned in Sphinx documentation, I inserted the abspath of my working directory, added <code>sphinx.ext.autodoc</code> to the list of extensions, and set <code>autosummary_generate</code> to True in <code>conf.py</code>.</p>
  
  <pre><code>import os
  import sys
  sys.path.insert(0, os.path.abspath('../..'))
  
  # Add any Sphinx extension module names here, as strings. They can be
  # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  # ones.
  extensions = [
      'sphinx.ext.autodoc',
      "sphinx.ext.autosummary", 
      'sphinx.ext.coverage', 
      'sphinx.ext.napoleon'
  ]
  
  autosummary_generate = True
  </code></pre>
  
  <p>Next, within <code>docs/index.rst</code>, I added a reference to the <code>refs/</code> folder.</p>
  
  <pre><code>.. toctree::
     :maxdepth: 2
  
     refs/index
  </code></pre>
  
  <p>The <code>refs/index.rst</code> has reference to <code>modA.rst</code> and <code>modB.rst</code>. </p>
  
  <pre><code>.. toctree::
     :maxdepth: 2
  
     modA
     modB
  </code></pre>
  
  <p>In <code>modA.rst</code> and <code>modB.rst</code>, I am trying to create autosummaries. </p>
  
  <p><code>modA.rst</code></p>
  
  <pre><code>Attributes
  ~~~~~~~~~~
  .. autosummary::
     :toctree: _autosummary
  
     modA.modA.create_job
  </code></pre>
  
  <p><code>modB.rst</code></p>
  
  <pre><code>Attributes
  ~~~~~~~~~~
  .. autosummary::
     :toctree: _autosummary
  
     modB.modB.get_jobs
  </code></pre>
  
  <p>While the code is working for <code>modA.rst</code>, it fails for <code>modB.rst</code>. The error says, </p>
  
  <pre><code>failed to import 'modB.modB.get_jobs': no module named modB.modB.get_jobs
  </code></pre>
  
  <p>I tried putting <code>.. currentmodule::modB</code> and <code>.. currentmodule::main</code> before the autosummary, but with no success. I even tried putting <code>.. module::modB</code> and <code>.. module::main</code> before autosummary, but even that is not working. I searched a lot on the internet, but unable to understand why it's not working. </p>
  
  <p><strong>Edit-1</strong>: Added <code>__init__.py</code> in both the folders.</p>