Python config ImportError
<p>I am working on a python project and whose directory structure looks like this,</p>

<pre><code>SEC-Edgar
├── SECEdgar
│   ├── __init__.py
│   ├── companylist.txt
│   ├── crawler.py
│   ├── crawler.pyc
│   ├── data.txt
│   └── test.py
├── config.py
├── requirements.txt
└── setup.py
</code></pre>

<p>I am trying to use config module inside <code>crawler.py</code> but it is giving an <code>ImportError</code>.</p>

<pre><code>Traceback (most recent call last):
  File "SECEdgar/test.py", line 3, in &lt;module&gt;
    from crawler import SecCrawler
  File "/Users/rahul/Code/SEC-Edgar/SECEdgar/crawler.py", line 9, in &lt;module&gt;
    from config import DEFAULT_DATA_PATH
ImportError: No module named config
</code></pre>

<p>The import statement in <code>crawler.py</code> is</p>

<pre><code> from config import DEFAULT_DATA_PATH
</code></pre>

<p>I am not able to understand how import works in python, particularly when it comes to different directories like importing from root to base directory.</p>

<p>Do I need to add <code>__init__.py</code> on root directory also, so that it becomes a package and then use <code>.</code> to import it? </p>

<p>Is there a better way to handle import or am I missing some fundamentals here?</p>