Django, virtualenv and Python in Ubuntu

Written by
Date: 2013-05-09 17:17:35 00:00


Today for the very first time I needed to install a Django server, so after reading a little some links I had stored from my experiments with Hyde (Which needed Phyton, virtualenv and virtualenvwrapper) I was able to have it installed.

So, let's see how to do it.

Update your Ubuntu server

sudo apt-get update && sudo apt-get upgrade

Install Ubuntu packages

sudo apt-get install python-setuptools python-dev build-essential

Install Python specific software

sudo easy_install pip

sudo pip install virtualenv virtualenvwrapper

Everything is installed now, all you need is to set up some variables:

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh

It is better to have those in your .bashrc file, you can modify them a little and then run this:

echo 'export WORKON_HOME=~/virtualenvs' >> ~/.bashrc
echo 'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bashrc
echo 'export PIP_VIRTUALENV_BASE=~/virtualenvs' >> ~/.bashrc

Now activete the variables:

source ~/.bashrc

Install Django

You are now ready to install Django. Just create a virtualenv space:

mkvirtualenv first_project
pip install django