relative import in pycharm 2018 does not work like relative import in python 3.6 : <p>I have read endless discussions on relative import in python, I think that one of the reasons it is so confusing is that it changes fro one Python version to another (my version is 3.6). But here the culprit seems to be PyCharm (unless i'm mistaken..) and i wonder if anyone came across a solution to this issue.
for a project with this layout:</p>

<pre><code>/project
    |-- __init__.py
    |---subfolder
            |-- __init__.py
            |-- AA.py
            |-- BB.py
</code></pre>

<p>Let's imagine that AA.py contains some fuction <code>myfunc</code>
inside the file <code>BB.py</code> if i write this import:</p>

<pre><code>from AA import myfunc
</code></pre>

<p>Then python works <strong>perfectly</strong>, but PyCharm sees it as an error:
<a href="https://i.stack.imgur.com/U0RLU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/U0RLU.png" alt="enter image description here"></a></p>

<p>So to make PyCharm happy i can add the <code>.</code> to the import and then the error is seemingly resolved:</p>

<pre><code>from .AA import myfunc
</code></pre>

<p>But then python is not happy, giving me the error: <code>ModuleNotFoundError: No module named '__main__.AA'; '__main__' is not a package</code></p>

<p>So to conclude, I use the import that actually works (i.e. <code>from AA import myfunc</code>) but it would be great if i could make PyCharm agree to it somehow because then it offers features such as auto complete, go to definition and so on.</p>

<p><strong>not duplicates:</strong>
I know it seems like this subject was discussed over and over but it also has many aspects. Here i'm talking about the pycharm aspect and therefore this topic is new as far as i know.</p>

<ol>
<li><a href="https://stackoverflow.com/questions/23830917/how-does-pycharm-handle-relative-imports-of-modules">How does PyCharm handle relative imports of modules?</a> - is a user who didn't add the root project dir to PYTHONPATH</li>
<li><a href="https://stackoverflow.com/questions/48702550/pycharm-auto-relative-imports">Pycharm auto relative imports</a> - is talking about auto-import feature that is not the case here</li>
<li><a href="https://stackoverflow.com/questions/45954981/subpackages-and-relative-imports-in-pycharm">Subpackages and relative imports in PyCharm</a> - is talking about import issue in python 2.7 but in here i'm not having any issue to import</li>
<li><a href="https://stackoverflow.com/questions/14132789/relative-imports-for-the-billionth-time">Relative imports for the billionth time</a> - offeres a great review of importing issues and also features a very detailed answer - none of it helps in my case because i don't have any import issue. not to mention that it is python 2.7 topic and not 3.x</li>
</ol>
