Import statement works on PyCharm but not from terminal
<p>PyCharm 2016.2.3, Mac OS X 10.11.1, Python 3.5 (Homebrew);</p>
<p>I have this folder structure</p>
<pre class="lang-none prettyprint-override"><code>project
  /somepackage
    /subpackage
     __init__.py   
     bar.py
   __init__.py
   foo.py
</code></pre>
<p><code>foo.py</code>:</p>
<pre class="lang-py prettyprint-override"><code>import somepackage.subpackage.bar
print(&quot;foo&quot;)
</code></pre>
<p><code>bar.py</code>:</p>
<pre class="lang-py prettyprint-override"><code>print(&quot;bar&quot;)
</code></pre>
<p>So my expected output is</p>
<pre><code>bar
foo
</code></pre>
<p>This works fine when run from PyCharm. However, when I run it from my terminal I get an ImportError:</p>
<pre><code>$ pwd
$ /home/project (not the actual path; just omitting some personal stuff)
$ python3.5 somepackage/foo.py
File &quot;foo.py&quot;, line 1, in &lt;module&gt;
import somepackage.subpackage.bar
ImportError: No module named 'somepackage'
</code></pre>
<p>I have found <a href="https://stackoverflow.com/questions/31348711/python-works-in-pycharm-but-not-from-terminal">this question</a>, which is about the same problem. However, none of the suggested solutions work for me, as I am indeed using the same Python interpreter as PyCharm does and I am currently in the folder that contains the <code>/somepackage</code> folder.</p>
<p>Does anyone have any other suggestions about how to solve this issue?</p>