No module named "xxx" in my project root folder
<p>My project is organized this way:</p>

<pre><code>ezrename/
âââ base/
âââ Images/
âââ shell
</code></pre>

<p>There are empties <strong>init</strong>.py files in ezrename, base and shell folders. Images is just a resource folder and don't have anything.</p>

<p>I have a module named ezrename/base/colors.py file, which implements the Colors class.</p>

<p>I have a module named ezrename/shell/baseshell.py, which implements the BaseShell class and imports Colors.</p>

<blockquote>
  <p>from ezrename.base import Colors</p>
</blockquote>

<p>But I get the following error:</p>

<pre><code>Traceback (most recent call last):
  File "/home/devaneando/Development/ezrename/shell/baseshell.py", line 6, in &lt;module&gt;
    from ezrename.base import Colors
ImportError: No module named 'ezrename'
</code></pre>

<p>So I decided to try</p>

<pre><code>from ..base import Colors
</code></pre>

<p>And gets</p>

<pre><code>Traceback (most recent call last):
  File "/home/devaneando/Development/ezrename/shell/baseshell.py", line 6, in &lt;module&gt;
    from ..base import Colors
SystemError: Parent module '' not loaded, cannot perform relative import
</code></pre>

<p>I have no idea what am I doing wrong. Can somebody explain how the imports works and what am I not doing right?</p>

<p>Python imports will work form the root of your project, so any imports in modules in subdirectories should import relative to that</p>

<p>So if you're running from a main module in ezrename/ then the import in baseshell.py should be:</p>

<p><code>from base import colors</code></p>

python python-3.x import