Virtualenv and Virtualenvwrapper
virtualenv
virtualenv is software for isolating python package environments (e.g. import paths).
virtualenv ENVsource ENV/bin/activeOnce the virtualenv is activated, the virtualenv’s python (and other executables) will be on your PATH and you will have a new environment variable,
VIRTUAL_ENV, that points to the path of the virtualenv, as well as a deactivate function for deactivating the virtualenv [2].
ENV/bin/deactivebuild with
virtualenv --system-site-packages ENV, virtual environment will inherit packages from/usr/lib/python2.7/site-packagesEnvironment variables and configuration files
- Environment variable:
VIRTUAL_<UPPER_NAME>eg: export VIRTUAL_PYTHON=/opt/python-3.3/bin/python - Config files:
~/.virtualenv/virtualenv.ini
- Environment variable:
| |
- bootstrap example:
| |
virtualenvwrapper
a set of extensions to
virtualenvinitialization steps:
export WORKON_HOME="$HOME/.virtualenvs"- source
/usr/local/bin/virtualenvwrapper.sh
mkvirtualenv foocdvirtualenvworkonlist all virtualenvworkon env1switch between environements withworkondeactivelssitepackagescdsitepackagessetvirtualenvprojectbind an existing virtualenv to an existing project
[1]: http://blog.ianbicking.org/site-packages-considered-harmful.html
[2]: https://developer.mozilla.org/en-US/docs/Python/Virtualenv