Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Setup ipython to work in a virtualenv
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment