Getting an embedded Python runtime to use the current active virtualenv

Brian Rossa br at
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?


PS - If you want some rep:

More information about the Python-list mailing list