Thursday, June 7, 2012

Deploy Virtual Enviroment


When a new application is deployed this could need a specific version of libraries for example a old version of python. Also, there are many advantages using a environment deployment isolate. Below it is a manual about how make a virtual environment for python.
First Step : Install pip
In a terminal we install via "pacman" the tool python-pip to make the installation of python packages easier.
$ sudo pacman -S python-pip
Second Step : Install virtualenv
Now, virtualenv is installed using python-pip.
$ sudo pip install virtualenv
Thirst Step : Install virtualenvwrapper
Virtualenvwapper is a set of extensions to Ian Bicking’s virtualenv tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies.
$ sudo pip install virtualenvwrapper
Fourth Step: Configure our first virtualenv
In this step we must define a folder to install the virtual environments and to keep the setting up files.  Once every variables and folder have been created, the last step is adding a folder and create the environment with python2.7 and don't define any news folder for the packages of the environment.
$ export WORKON_HOME=$HOME/.virtualenvs
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkdir -p $WORKON_HOME

$ mkdir -p $WORKON_HOME/env1
$ mkvirtualenv -p python2.7 --no-site-packages --distribute $WORKON_HOME/env1
When in the console we'd same like that (env1) $, we are inside of virtual environment and now we can install every thing are needed to develop our app. For example we start with django.

(env1) $ pip install django
(env1) $ pip install mysql-python

Sixth Step: Restore in virtualenv
When the terminal start, the environment is not active, if we want to use it again, we just have to run the following command from anywhere in the console.
$ workon env1


 

No comments:

Post a Comment