IPython import failure and python sys.path in general
===

I'm following this [post][1] to make one ipython rule all the virtualenvs.

From what I understand, the main idea of the post is that when in a virtualenv, ipython can not find its modules.

    (a-virtualenv)me@pc:~$ ipython
    Traceback (most recent call last):
      File "/usr/bin/ipython", line 19, in <module>
        from IPython.frontend.terminal.ipapp import launch_new_instance
    ImportError: No module named IPython.frontend.terminal.ipapp

To work around this, I add this to my /usr/bin/ipython

    import sys
    if "/usr/lib/python2.7/dist-packages" not in sys.path:
        sys.path.append("/usr/lib/python2.7/dist-packages")

This trick works for Balthazar. But in my case, I get this

    Traceback (most recent call last):
      File "/usr/bin/ipython", line 18, in <module>
        from IPython.frontend.terminal.ipapp import launch_new_instance
      File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 46, in <module>
        from .frontend.terminal.embed import embed
      File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/embed.py", line 37, in <module>
        from IPython.frontend.terminal.ipapp import load_default_config
      File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 38, in <module>
        from IPython.core.completer import IPCompleter
      File "/usr/lib/python2.7/dist-packages/IPython/core/completer.py", line 84, in <module>
        from IPython.utils import generics
      File "/usr/lib/python2.7/dist-packages/IPython/utils/generics.py", line 19, in <module>
        from IPython.external.simplegeneric import generic
      File "/usr/lib/python2.7/dist-packages/IPython/external/simplegeneric/__init__.py", line 4, in <module>
        from _simplegeneric import *
    ImportError: No module named _simplegeneric

I thought maybe I should add `/usr/lib/python2.7/dist-packages/IPython/external` to `sys.path` in `/usr/bin/ipython` as well. What I get is 

    Traceback (most recent call last):
      File "/usr/bin/ipython", line 18, in <module>
        from IPython.frontend.terminal.ipapp import launch_new_instance
      File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 43, in <module>
        from .config.loader import Config
      File "/usr/lib/python2.7/dist-packages/IPython/config/loader.py", line 27, in <module>
        from IPython.utils.path import filefind, get_ipython_dir
      File "/usr/lib/python2.7/dist-packages/IPython/utils/path.py", line 24, in <module>
        from IPython.utils.process import system
      File "/usr/lib/python2.7/dist-packages/IPython/utils/process.py", line 27, in <module>
        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 <module>
        from IPython.utils import text
      File "/usr/lib/python2.7/dist-packages/IPython/utils/text.py", line 27, in <module>
        from IPython.external.path import path
    ImportError: cannot import name path

This error occurred on line 43 of `IPython/__init__py`, but the previous one occurred on line 46.

1. How can I make ipython work with virtualenv?

2. How can adding `/usr/lib/python2.7/dist-packages/IPython/external` to `sys.path` resulting a new error?

3. What should I read to get a better understanding of python import path?

Thanks!

  [1]: http://isbullsh.it/2012/04/Embed-ipython-in-virtualenv/
