12

Appears to be installing Django 1.3.1 in Ubuntu 12.04. How can I get Django 1.6 installed?

sudo apt-get install python-django
Braiam
  • 67,791
  • 32
  • 179
  • 269

2 Answers2

18

While you can install it manually (setup.py), I recommend using the Python package manager as it is easier to install, maintain and upgrade.

  1. Install Pip, the Python package manager.

    sudo apt-get install python-pip
    
  2. Optionally, but recommended, upgrade pip, using itself:

    sudo pip install -U pip
    
  3. Install the latest stable version of Django:

    sudo pip install Django
    

    This installs 1.6.2 at the time of writing(check here the latest pypi version).

To install a specific version, add a requirement specifier like this:

sudo pip install Django==1.6.2

Note that APT, the Debian/Ubuntu package management will still report the older version installed and it is still installed as well. APT installs in dist-packages paths while Pip installs in the site-packages paths. The latter takes precedence, so that's locally installed packages will be chosen. See also: What's the difference between dist-packages and site-packages?

gertvdijk
  • 67,947
  • 1
    If you are sceptic like me, you can try "pip install --user Django", without using sudo, because I hate to mess up with system package – rafee Dec 23 '13 at 12:07
  • 1
    @rafee Yes, true, and I know. You can also use a virtualenv, or even a pyenv. I think that's out of scope for this question, though. I just wanted to provide a (better) alternative to the existing answer. – gertvdijk Dec 23 '13 at 12:09
  • sudo pip install is a bad practice, which may work for django but can really screw up someone's system in other situations. Don't undermine the advantages of having Ubuntu manage your packages. The clean way to do it is with virtualenvwrapper. – nealmcb Aug 20 '14 at 03:56
10

First remove the previously installed django 1.3.1 version by deleting the django folder inside /usr/local/lib/pythonx.x/dist-packages(x.x denotes the version of python).Then follow the below steps,

  • Download Django 1.6 from here.

  • Open the terminal and move to the directory where you placed the Django 1.6.

    cd path/to/driectory/which/contains/django1.6.tar.gz

  • Extract the django1.6.tar.gz by running the below command.

    tar -xzvf Django-1.6.tar.gz

  • Move to the Django-1.6 directory

    cd Django-1.6

  • Run the below command to install Django-1.6

    sudo python setup.py install

Avinash Raj
  • 78,556
  • 1
    Only works if no older django-version was installed before... I had some issues with removing an older django installation. – Ice Dec 09 '13 at 22:27