I’m using pydev with Eclipse and virtualenv with python2.7 on Debian Squeeze
My python script requires the variable os.environ['VIRTUAL_ENV'] but there is no VIRTUAL_ENV key when I debug.
However if I type in the terminal:
. /my_virtualenv/bin/activate
python
import os
os.environ['VIRTUAL_ENV']
then I can see VIRTUAL_ENV is in the variable os.environ
Any clues?
It appears that virtualenv sets the
VIRTUAL_ENVvariable as part of it’s activate script. Pydev doesn’t run that activate script, so it doesn’t have knowledge of that environment variable.You can set it in the run configuration though.
VIRTUAL_ENVas the name and the value that you desire.