Installing Django on Ubuntu
If you want to install Django by creating a virtual environment, follow this tutorial instead.
Assumption: There is no older version of Django that is currently installed in the system. If there is, click here.
You can install Django using the packages from the Ubuntu repositories. However, this tutorial is all about installing Django using the archives from the official website.
We will be using the terminal. As of this writing, the latest version is Django 1.3.1. First, download the archive.
wget http://www.djangoproject.com/download/1.3.1/tarball/
Now, extract the archive.
tar xzvf Django-1.3.1.tar.gz
Go inside the newly created directory:
cd Django-1.3.1
Install Django:
sudo python setup.py install
Wait for the installation to finish. If you are planning to use MySQL as your database, you might want to install the python-mysqldb package to allow the communication between Python and MySQL.
sudo apt-get install python-mysqldb
To verify whether the installation was successful or not, start the interactive mode of python by issuing the “python” command and try the following codes:
>>> import django >>> print django.get_version() 1.3.1
That’s it. It’s time to move to the tutorials.
Is there a special reason to install from source? If it’s just to get the latest version, you can use “pip install django” (requires package python-pip) and unlike the source installation, you can get rid of it easily via “pip uninstall django”. pip also works inside a virtualenv so you can run different versions of django for different projects.