Python - No module named
<p>I have the following code with few modules:</p>

<pre><code>import Persistence.Image as img
import sys

def main():
    print(sys.path)
    original_image = img.Image.open_image()


if __name__ == "__main__":
    main()
</code></pre>

<p>(I've created my own Image module)</p>

<p>And so I'm getting the following error claiming that the Persistence module does not exist:</p>

<pre><code>Traceback (most recent call last):
  File "/home/ulises/PycharmProjects/IntelligentPuzzle/Puzzle.py", line 1, in &lt;module&gt;
    import Persistence.Image as img
ImportError: No module named Persistence.Image
</code></pre>

<p>I've been searching for this problem here but can't find anything that worked to solve this as the directory tree seems to be correct as you can see on this image:</p>

<p><a href="http://i.stack.imgur.com/EgAkA.png" rel="nofollow"><img src="http://i.stack.imgur.com/EgAkA.png" alt="enter image description here"></a></p>

<p>I'm using ubuntu if it's any use.</p>

<p>Thanks and regards!</p>

<p><code>Persistence</code> package does not exist in that source tree. There is a <em>"Persistence"</em> directory there, but it is not a package, because it does not contain a <code>__init__.py</code> file.</p>

<p>From the <a href="https://docs.python.org/2/tutorial/modules.html#packages" rel="nofollow">Python documentation</a>:</p>

<blockquote>
  <p>The <code>__init__.py</code> files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, <code>__init__.py</code> can just be an empty file, but it can also execute initialization code for the package or set the <code>__all__</code> variable, described later.</p>
</blockquote>

python python-2.7