def init_virtualenv(self):
if '<STR_LIT>' not in os.environ:<EOL><INDENT>return<EOL><DEDENT>if sys.executable.startswith(os.environ['<STR_LIT>']):<EOL><INDENT>return<EOL><DEDENT>warn("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>if sys.platform == "<STR_LIT:win32>":<EOL><INDENT>virtual_env = os.path.join(os.environ['<STR_LIT>'], '<STR_LIT>', '<STR_LIT>') <EOL><DEDENT>else:<EOL><INDENT>virtual_env = os.path.join(os.environ['<STR_LIT>'], '<STR_LIT>',<EOL>'<STR_LIT>' % sys.version_info[:<NUM_LIT:2>], '<STR_LIT>')<EOL><DEDENT>import site<EOL>sys.path.insert(<NUM_LIT:0>, virtual_env)<EOL>site.addsitedir(virtual_env)<EOL>
Add a virtualenv to sys.path so the user can import modules from it.
        This isn't perfect: it doesn't use the Python interpreter with which the
        virtualenv was built, and it ignores the --no-site-packages option. A
        warning will appear suggesting the user installs IPython in the
        virtualenv, but for many cases, it probably works well enough.

        Adapted from code snippets online.

        http://blog.ufsoft.org/2009/1/29/ipython-and-virtualenv