Skip to content

Instantly share code, notes, and snippets.

@EnigmaCurry
Created February 9, 2011 01:52
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save EnigmaCurry/817737 to your computer and use it in GitHub Desktop.
Save EnigmaCurry/817737 to your computer and use it in GitHub Desktop.
Setup ipython to work in a virtualenv
#Call this inside ~/.ipython/ipy_user_conf.py 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))'],
stdout=subprocess.PIPE).communicate()[0]
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