Monday, 24 September 2018

How to set environment variables in virtualenv

If I have python script which activates the virtualenv like this:

#!/path/to/venv/bin/python

How can I set variables for this script without modifying this script?

I want this environment variable to active for all scripts which use this virtualenv.

This means modifying this script is not a solution, since there are twenty scripts, and I don't want to modify twenty scripts.

Writing a shell wrapper-script around the python scripts would work, but I would like to avoid this.

In the past I though a custom sitecustomize.py can be used for start-up code. But Ubuntu (AFAIK the only distribution which does this) comes with an own sitecustomize.py file, with the effect that my sitecustomize.py does not get called. See https://bugs.launchpad.net/ubuntu/+source/python2.5/+bug/197219



from How to set environment variables in virtualenv

No comments:

Post a Comment