Thursday, December 27, 2012

Python Virtual Environment Setup

0 comments

I had to install python 2.7 for an application where I did not want to change the default configuration of Python 2.4. That's why I choose to use vurtualenv.
virtualenv is a virtual python environment builder. pypi.python.org/pypi/virtualenv has detail information about virtualenv.

I configured my environment using the following steps:-

Download virtualenv


wget http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.8.4.tar.gz

Extract  it

tar -zxvf virtualenv-1.8.4.tar.gz

Create virtual environment

I keep my default python 2.4 intact. I installed python 2.7 from source in /extra/python2.7 and use that library to create virtual environment.

cd /root/virtualenv-1.8.4
/extra/python2.7/bin/python  virtualenv.py /extra/app_python
cd app_python
ls -l
total 12
drwxr-xr-x 2 root root 4096 Dec 27 15:22 bin
drwxr-xr-x 2 root root 4096 Dec 27 15:22 include
drwxr-xr-x 3 root root 4096 Dec 27 15:22 lib

 

Activate this environment

[root@rumman app_python]# source bin/activate
(app_python)[root@rumman app_python]#

Now if I use python, it uses python 2.7.
(app_python)[root@rumman app_python]# python
Python 2.7.3 (default, Dec 27 2012, 12:28:28)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

 

Return to normal mode

(app_python)[root@rumman app_python]# deactivate
[root@rumman erp_python]#
 

Leave a Reply

Labels