Getting an embedded Python runtime to use the current active virtualenv

Brian Rossa br at co57.com
Wed Jan 25 13:36:15 EST 2012


Hi all,

I've had this question up on Stackoverflow for a while but no one has
yet come along with an authoritative answer.

I've written some C code that interfaces with a Python package through
an embedded Python runtime. All of it works pretty well except that
now I want the embedded runtime to use a virtualenv. The workflow that
I'm used to with virtualenvs starts with "source activate" but,
AFAICT, all that does is set the $PATH to prefer a special executable;
it doesn't do anything special to other environment variables. I could
be missing something here, but trying to "discover" the appropriate
$PYTHONHOME and $PYTHONPATH from the $PATH and then feed them to the
embedded runtime seems like a kludge at best. I'm guess that there has
to be a *right* way to do this. Could somebody give me a clue?

Thanks!
~Brian

PS - If you want some rep:
http://stackoverflow.com/questions/7492855/getting-an-embedded-python-runtime-to-use-the-current-active-virtualenv



More information about the Python-list mailing list