title: Cannot import module from source directory in pycharm
body: <p>This question has been asked before - but i could not solve it with any of the answers. I opned a project folder in pycharm (<em>note</em> that the project folder is not in the <code>../PycharmProject/...</code> directory. </p>
  
  <p>My structure is super basic:</p>
  
  <pre><code>project_title (folder)
               |--src (folder)
                    |-- app.py  
                    |-- pipeline_tools (folder)
                       |-- helpers.py
                       |-- other modules
  </code></pre>
  
  <p>I tried all possible solutions and combinations but when in <code>app.py</code> i try to import a function from either modules in <code>tools</code> I get errors. </p>
  
  <p>Additionally, Pycharm underlines in red the following statement:</p>
  
  <p>1) <code>from pipeline_tools.helpers import a_certain_function</code> (red underline with "Unresolved reference")</p>
  
  <p>But the following gives me no red:</p>
  
  <p>2) <code>from .pipeline_tools.helpers import a_certain_function</code> (no red underline, note the relative import)</p>
  
  <p>The fact that I have or not a <code>__init__.py</code> inside the modules changes nothing - I still get the following two errors:</p>
  
  <p>For 1)</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;input&gt;", line 1, in &lt;module&gt;
    File "/home/gabriele/pycharm-2019.1.1/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
      module = self._system_import(name, *args, **kwargs)
  ModuleNotFoundError: No module named 'pipeline_tools'
  
  </code></pre>
  
  <p>for 2)</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;input&gt;", line 1, in &lt;module&gt;
    File "/home/gabriele/pycharm-2019.1.1/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
      module = self._system_import(name, *args, **kwargs)
  ModuleNotFoundError: No module named '__main__.pipeline_tools'; '__main__' is not a package
  </code></pre>
  
  <p>Stuff I made sure I tried:</p>
  
  <p>1) Go to <code>settings &gt; Project Structure</code> check <code>content root</code> is <code>.../project_title</code> and marked it as "source" - it's blue. </p>
  
  <p>2) Add <code>__init__.py</code> in the <code>pipeline_tools</code> folder and in the <code>/src</code> folder, tried all possible combinations. </p>
  
  <p>3) Use the below code to check the path to the project folder is part of the path string - it is <strong>at the end</strong></p>
  
  <pre><code>import sys
  print(sys.path)
  </code></pre>
  
  <p>4) Use the below code to move the project path to the beginning of the sys.path:
  <code>sys.path.insert(0,'path/to/project_title')</code></p>
  
  <p>5) Just tried to print <code>PYTHONPATH</code> like this:</p>
  
  <pre><code>os.environ['PYTHONPATH'].split(os.pathsep)
  </code></pre>
  
  <p>and the <strong>directory of my project is not in it</strong></p>
  
  <p>I am a bit at a loss right now. Have no idea what is going on.</p>