How to import python file located in same subdirectory in a pycharm project
<p>I have an input error in pycharm when debugging and running.</p>

<p>My project structure is rooted properly, <code>etc./HW3/.</code> so that <code>HW3</code> is the root directory. </p>

<p>I have a subfolder in HW3, <code>util</code>, and a file, <code>util/util.py</code>.  I have another file in <code>util</code> called <code>run_tests.py</code>. </p>

<p>In <code>run_tests.py</code>, I have the following import structure, </p>

<pre><code>from util.util import my_functions, etc.
</code></pre>

<p>This yields an input error, <code>from util.util import load_dataset,proportionate_sample
ImportError: No module named 'util.util'; 'util' is not a package</code></p>

<hr>

<p>However, in the exact same project, in another directory (same level as <code>util</code>) called <code>data</code>, I have a file <code>data/data_prep.py</code>, which also imports functions from <code>util/util.py</code> using a similar import statement...and it runs without any problems.  </p>

<hr>

<p>Obviously, I am doing this in the course of doing a homework, so please understand: this is ancillary to the scope of the homework. </p>

<hr>

<p>The problem goes away when I move the file to another directory.  So I guess this question is <strong>How do I import a python file located in the same directory in a pycharm project?</strong>  Because pycharm raises an error if I just do <code>import util</code> and prompts me to use the full name from the root. </p>