-
-
Save lxneng/1098859 to your computer and use it in GitHub Desktop.
Setup ipython to work in a virtualenv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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