title: Subdirectory import giving error only when module gets imported from package
body: <p>I've this package called <a href="https://pypi.org/project/classevivaAPI/0.2.0.dev3/" rel="nofollow noreferrer"><code>classevivaAPI</code></a> on <code>PyPI</code> (you can find it on <code>GitHub</code> <a href="https://github.com/Lioydiano/Classeviva" rel="nofollow noreferrer"><code>here</code></a>), of which I've for obvious reasons a <code>git</code> clone on my computer.</p>
  <hr />
  <pre><code># main.py
  from paths import paths
  from variables.variables import *
  </code></pre>
  <p>In <code>main.py</code> I've the <code>import</code>s above, when <code>main.py</code> is the file marked as modified (with an <code>M</code>) below.</p>
  <p><a href="https://i.stack.imgur.com/egCEN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/egCEN.png" alt="This is the file structure" /></a></p>
  <hr />
  <p>I'm testing this package with <code>test.py</code>, the <code>gitignore</code>d file at the bottom of the screenshot, which has the following content:</p>
  <pre><code>#!\usr\bin\env python3
  from classeviva import Session, Valutazioni, Note, Registro
  from classeviva.variables import NoteSortBy
  
  if __name__ == &quot;__main__&quot;:
      # Some code here
  </code></pre>
  <p><code>classeviva</code> is the module included in the package <code>classevivaAPI</code>, and <code>test.py</code> is importing it via <code>pip</code>, I tested it and it gave me the same problem even if runned from a directory very far from <code>src/</code> and in general <code>src/classeviva</code>.</p>
  <p>When I ran it it gave me the following error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;d:\Python\Python\Classeviva\test.py&quot;, line 2, in &lt;module&gt;
      from classeviva import Session, Valutazioni, Note, Registro
    File &quot;C:\Users\matti\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\classeviva\__init__.py&quot;, line 1, in &lt;module&gt;
      from .main import *
    File &quot;C:\Users\matti\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\classeviva\main.py&quot;, line 3, in &lt;module&gt;
      from paths import paths
  ModuleNotFoundError: No module named 'paths'
  </code></pre>
  <p>I was quite confused since I had followed what explained <a href="https://www.pythonpool.com/python-import-from-subdirectory/" rel="nofollow noreferrer"><code>here</code></a>, <a href="https://www.delftstack.com/howto/python/python-import-from-subdirectory/" rel="nofollow noreferrer"><code>here</code></a> and expecially <a href="https://docs.python.org/3/reference/import.html#submodules" rel="nofollow noreferrer"><code>here</code></a>.</p>
  <hr />
  <p>So I had the idea to copy paste the <code>if __name__ == '__main__'</code> block of <code>test.py</code> at the bottom of <code>main.py</code>, and surprisingly <strong>it ran perfectly</strong> without giving me any error.</p>
  <hr />
  <p>Does anybody know what is happening? Have you ever experienced this? Do you know how to fix it or what I'm doing wrong?</p>
  <h1>Edit</h1>
  <hr />
  <p>I searched for the module (<code>classeviva</code>) into the folder on my hard disk containing all the pip-installed modules, and I found it.</p>
  <p>I opened its <code>main.py</code>, and the <code>Visual Studio Code</code> intellisense told me the same thing as <code>CPython</code> did before: there was no subfolder called <code>path</code>.
  <a href="https://i.stack.imgur.com/9hXtM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9hXtM.png" alt="" /></a></p>