ImportError: No module named package
<p>I found importing modules in Python complicated, so I'm doing experiments to clear it up. Here is my file structure:</p>

<pre><code>PythonTest/
  package/
    __init__.py
    test.py
</code></pre>

<p>Content of <code>__init__.py</code>:</p>

<pre><code>package = 'Variable package in __init__.py'
from package import test
</code></pre>

<p>Content of <code>test.py</code>:</p>

<pre><code>from package import package
print package
</code></pre>

<p>When I stay out of <code>package</code>(in <code>PythonTest</code>), and execute <code>python package/test.py</code>, I get:</p>

<pre><code>Traceback (most recent call last):
  File "package/test.py", line 1, in &lt;module&gt;
    from package import package
ImportError: No module named package
</code></pre>

<p>The expected output is <code>Variable package in __init__.py</code>. What am I doing wrong?</p>

<hr>

<p>However, I can get the expected output in the interactive mode:</p>

<pre><code>sunqingyaos-MacBook-Air:PythonTest sunqingyao$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import package
Package in __init__.py
</code></pre>