How to Setup Python Virtual Environment In Ubuntu

Posted on  7/26/2015
In this tutorial , I am going to show you that how to Install , configure and use python virtual environment in Ubuntu . Python Virtual environment provide flexibility to switch between environments easily according to your requirements , [python virtualenvs]( create isolated python environment which contains all project specific dependencies separately .

Please Note : These steps demonstrated and tested on Ubuntu 15.04 but they will work same on other Ubuntu and Debian based distributions .


apt-get install build-essential

# Install Python Development package and pip 

apt-get install python2.7-dev python-setuptools
sudo easy_install pip

Now Install virtualenv

sudo pip install virtualenv

After Install You can use virtualenv to setup virtual environment

cd your_project_folder
virtualenv venv

then activate the virtual environment

source venv/bin/activate

Before using virtualenv freeze pip and pipe that to requirements.txt file

pip freeze > requirements.txt

then after activation virtualenv install all dependencies using pip

pip install -r requirements.txt

additionally you can install virtualenvwrapper , which provide awesome setup of tools which make working with virtualenv easy and pleasant .

read more about virtualenvwrapper

to deactivate virtual environment :


Python Virtual Environment
Python Virtual Environment

Useful Links

1 .virtualenvs
2 .virtualenvwrapper

I hope this post will help you to setup virtual environment in you system . thanks for reading .

  • Home
  • About