Virtualenv and Virtualenvwrapper
virtualenv
virtualenv is software for isolating python package environments (e.g. import paths).
virtualenv ENV
source ENV/bin/active
Once 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/deactive
build with
virtualenv --system-site-packages ENV
, virtual environment will inherit packages from/usr/lib/python2.7/site-packages
Environment 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
virtualenv
initialization steps:
export WORKON_HOME="$HOME/.virtualenvs"
- source
/usr/local/bin/virtualenvwrapper.sh
mkvirtualenv foo
cdvirtualenv
workon
list all virtualenvworkon env1
switch between environements withworkon
deactive
lssitepackages
cdsitepackages
setvirtualenvproject
bind 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