title: IPython import failure and python sys.path in general
body: <p>I'm following this <a href="http://isbullsh.it/2012/04/Embed-ipython-in-virtualenv/">post</a> to make one ipython rule all the virtualenvs.</p>
  
  <p>From what I understand, the main idea of the post is that when in a virtualenv, ipython can not find its modules.</p>
  
  <pre><code>(a-virtualenv)me@pc:~$ ipython
  Traceback (most recent call last):
    File "/usr/bin/ipython", line 19, in &lt;module&gt;
      from IPython.frontend.terminal.ipapp import launch_new_instance
  ImportError: No module named IPython.frontend.terminal.ipapp
  </code></pre>
  
  <p>To work around this, I add this to my /usr/bin/ipython</p>
  
  <pre><code>import sys
  if "/usr/lib/python2.7/dist-packages" not in sys.path:
      sys.path.append("/usr/lib/python2.7/dist-packages")
  </code></pre>
  
  <p>This trick works for Balthazar. But in my case, I get this</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/bin/ipython", line 18, in &lt;module&gt;
      from IPython.frontend.terminal.ipapp import launch_new_instance
    File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 46, in &lt;module&gt;
      from .frontend.terminal.embed import embed
    File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/embed.py", line 37, in &lt;module&gt;
      from IPython.frontend.terminal.ipapp import load_default_config
    File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 38, in &lt;module&gt;
      from IPython.core.completer import IPCompleter
    File "/usr/lib/python2.7/dist-packages/IPython/core/completer.py", line 84, in &lt;module&gt;
      from IPython.utils import generics
    File "/usr/lib/python2.7/dist-packages/IPython/utils/generics.py", line 19, in &lt;module&gt;
      from IPython.external.simplegeneric import generic
    File "/usr/lib/python2.7/dist-packages/IPython/external/simplegeneric/__init__.py", line 4, in &lt;module&gt;
      from _simplegeneric import *
  ImportError: No module named _simplegeneric
  </code></pre>
  
  <p>I thought maybe I should add <code>/usr/lib/python2.7/dist-packages/IPython/external</code> to <code>sys.path</code> in <code>/usr/bin/ipython</code> as well. What I get is </p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/bin/ipython", line 18, in &lt;module&gt;
      from IPython.frontend.terminal.ipapp import launch_new_instance
    File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 43, in &lt;module&gt;
      from .config.loader import Config
    File "/usr/lib/python2.7/dist-packages/IPython/config/loader.py", line 27, in &lt;module&gt;
      from IPython.utils.path import filefind, get_ipython_dir
    File "/usr/lib/python2.7/dist-packages/IPython/utils/path.py", line 24, in &lt;module&gt;
      from IPython.utils.process import system
    File "/usr/lib/python2.7/dist-packages/IPython/utils/process.py", line 27, in &lt;module&gt;
      from ._process_posix import _find_cmd, system, getoutput, arg_split
    File "/usr/lib/python2.7/dist-packages/IPython/utils/_process_posix.py", line 27, in &lt;module&gt;
      from IPython.utils import text
    File "/usr/lib/python2.7/dist-packages/IPython/utils/text.py", line 27, in &lt;module&gt;
      from IPython.external.path import path
  ImportError: cannot import name path
  </code></pre>
  
  <p>This error occurred on line 43 of <code>IPython/__init__py</code>, but the previous one occurred on line 46.</p>
  
  <ol>
  <li><p>How can I make ipython work with virtualenv?</p></li>
  <li><p>How can adding <code>/usr/lib/python2.7/dist-packages/IPython/external</code> to <code>sys.path</code> resulting a new error?</p></li>
  <li><p>What should I read to get a better understanding of python import path?</p></li>
  </ol>
  
  <p>Thanks!</p>
  
  <p>PS:
  normal IPython sys.path</p>
  
  <pre><code>['',
   '/usr/bin',
   '/usr/lib/python2.7',
   '/usr/lib/python2.7/plat-linux2',
   '/usr/lib/python2.7/lib-tk',
   '/usr/lib/python2.7/lib-old',
   '/usr/lib/python2.7/lib-dynload',
   '/usr/local/lib/python2.7/dist-packages',
   '/usr/lib/python2.7/dist-packages',
   '/usr/lib/python2.7/dist-packages/PIL',
   '/usr/lib/python2.7/dist-packages/gst-0.10',
   '/usr/lib/python2.7/dist-packages/gtk-2.0',
   '/usr/lib/pymodules/python2.7',
   '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
   '/usr/lib/python2.7/dist-packages/ubuntuone-client',
   '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
   '/usr/lib/python2.7/dist-packages/ubuntuone-couch',
   '/usr/lib/python2.7/dist-packages/ubuntuone-installer',
   '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
   '/usr/lib/python2.7/dist-packages/IPython/extensions']
  </code></pre>