Setting up Virtual Environment

Virtual Environment is a tool to create isolated Python environments. virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need.

For example, you can work on a project which requires Django 1.3 while also maintaining a project which requires Django 1.0.

A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.
Installation:
step 1:
>> sudo easy_install virtualenv

step 2:
Creating the First Virtual Environment

>> mkdir first_evn

>> virtualenv first_env/test_env
or
>> virtualenv first_env/test_env --no-site-packages

-no-site-packages:  If you don’t want to use any preinstalled packages from my operating system

step 3: activating environment

>> source /first_env/test_env/bin/activate

step 4: Deactivating Environment

>> deactivate

Important: if you have more than one versions of Python on your server or local system and you want to create a viertualenv for a specific version of python then please replace the step 2 with following  
For Ubuntu >> virtualenv --python=/usr/bin/python3.3 first_env/test_env For Window >> virtualenv --python=c:\Python33\python.exe first_env/test_env For mac virtualenv --python=python3.4 test_env Adding virtual env path in .base_profile file >>> pico ~/.bash_profile And add live alias ff='source ~/PATH_FROM_ROOT/VIRTUAL_ENV_NAME/bin/activate'

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s