VirtualEnv is of incredible help for anybody using frequently changing new Python frameworks. Wanna test one project with Pylons 0.9.5 and another with Pylons 0.9.6? Need SQLAlchemy 0.4.3 while packaged 0.4.1 is required by some other app? Need to install some libraries without root
access? No problem.
The only problem is somewhat unclear documentation. So here is my short recipe.
Preparation
Commands by root
:
$ easy_install -U SetupTools
(only if installed SetupTools is older than 0.6c7) and
$ easy_install -U virtualenv
Environment setup
Either:
$ python -m virtualenv ~/PyEnvs/DjangoAlpha
or
$ python -m virtualenv --no-site-packages \
~/src/migzdev/release_test/pyenv
The former uses system libraries too, the latter makes system site-packages
invisible while working inside the environment.
Of course any directory name can be used.
Usage - method 1
$ ~/PyEnvs/PylonsBeta/bin/easy_install -U PasteScript
$ ~/PyEnvs/PylonsBeta/bin/paster --help
$ ~/PyEnvs/PylonsBeta/bin/python /some/script.py
and so on. One an also specify /path/to/env/bin/python
as Python
path to WingIDE or other GUI.
Usage - method 2
$ . ~/PyEnvs/DjangoTest/bin/activate
(note dot!). The shell prompt will be changed to contain the environment name (nice reminder) and simple commands work in environment:
(DjangoTest)$ easy_install -U Django
(DjangoTest)$ python myscript.py
Once finished:
(DjangoTest)$ deactivate