How to install django using virtual environment

Virtual environment is made when you want to run different version on single system. In this example I am going to setup a virtualenv for installing django 1.9. This is because the default version of python in the ubuntu system is 2.7(approx.) and the django is in the version 1.7. And the python is very important in the case of Ubuntu graphics. (If you want to test this try to remove python from your system and get ready to waste 2-3 hours of your time trying to figure out what happened. You might have to install Ubuntu again).

Now it’s time to start creating the virtual environment. So the before installing virtualenv you need to have pip installed in your system. For that use this command.
sudo apt-get install python-pip
Now install virtualenv
sudo pip install virtualenv
and then
sudo pip install virtualenv –upgrade for the most recent version.
Now make a directory where you want to run the virtualenv.
mkdir django1_9_7
cd django1_9_7
Now create a virtualenv inside this folder.
virtualenv .
Now apply this command everytime you want to start the use the virtualenv
source bin/activate
Now you are in the virtualenv and you can see the various packages inside this env are going to stay in this env only. Use this command to find the packages in the env
pip freeze
Now use this command to install django
pip install django
Now you can start a django project inside this folder.
django-admin startproject myprojectname.
This env will as same as the way as the real installed softwares will work..

2 thoughts on “How to install django using virtual environment

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s