Setup ipython to work in a virtualenv

Monday, August 29, 2011

add this script to \~/.ipython/

#Call this inside ~/.ipython/ main()

import sys
import subprocess
from os import environ

if 'VIRTUAL_ENV' in environ:
    #This is kludgy but it works; grab the right sys.path from the virtualenv python install:
    path = subprocess.Popen(['python', '-c','import sys;print(repr(sys.path))'],
    sys.path = eval(path)
    del path

del sys, subprocess, environ


This entry was tagged Python

comments powered by Disqus

© 2009-2013 All rights reserved. Powered by Pyramid

go to Top