How To Install Django

Published on June 4, 2012
How To Install Django


Django is a free, open-source program that streamlines Python programming to help developers create “clean, pragmatic design.”

Step One — Install Python and Pip

The virtual private server needs to be equipped with Python before Django can be installed. The recommended installation method is to create an isolated Python environment, called a virtualenv, where any changes made to the overall virtual server will not affect the Python projects. An additional benefit of using virtualenv is that it does not require root access to install or manage. Django itself can then be installed within the virtualenv with the help of Pip, a tool that makes installation, upgrades, and removals of Python Packages extremely easy.

You can install Pip on Ubuntu through apt-get:

  1. sudo apt-get install python-pip

Go ahead and install Python:

  1. curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py

Once that process has completed, we need to create the new virtualenv.

  1. python virtualenv.py example_env

The next step is to activate the virtualenv so that all further changes and installations will be done only within example_env

  1. . example_env/bin/activate

Step Two — Install Django

In the previous step, we setup the environment to install Django. Now using the easy pip installer, we can get Django on our droplet.

  1. pip install Django

For future reference, you can use these commands to make changes to your version of Django or any other Python packages:

  1. pip install --upgrade Django
  1. pip uninstall Django

You now have Django installed on your VPS!

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us

About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Actually I would install virtualenv in the canonical way:

sudo apt-get install python-pip
sudo apt-get install python-virtualenv
virtualenv example_env
source example_env/bin/activate
pip install Django

And just because on my system virtualenv.py from github fails!

This comment has been deleted

    Problem solved Installed it the canonical way. Thanks

    When I try this command frans@frans-eMachines-D620:~$ python virtualenv.py example_env

    I get the error message python: can’t open file ‘virtualenv.py’: [Errno 2] No such file or directory

    I also had to install curl

    I am sorry the solution my be obvious, but I am stumped.

    @ernesto.troiano +1 for identifying problem and a working solution!

    Kamal Nasser
    DigitalOcean Employee
    DigitalOcean Employee badge
    August 13, 2013

    @klimatima: Simply clone your git repo so you have the code on your droplet.

    hi, i installed django as per the instructions here. what further steps do i need to take in order to get my django code running from either my localhost or from my git repo (hosted on bitbucket)? can you provide me with the relevant steps to take. i have also installed git on my virtual server thanks in advance

    Kamal Nasser
    DigitalOcean Employee
    DigitalOcean Employee badge
    July 3, 2013

    @mtufekyapan: What do you mean? Do you have a webserver running?

    I installed Django. I upload my django codes via ftp. Now i can see my codes but they didn’t work just see they as a file. How i can run this code on server?

    I’m confused, are the steps under “On other systems, you can take the following steps:” on installing pip missing? Because after that it seems to point out that we need to install virtual_env, nothing about pip is mentioned.

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Join the Tech Talk
    Success! Thank you! Please check your email for further details.

    Please complete your information!

    Featured on Community

    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

    Become a contributor

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

    Learn more
    DigitalOcean Cloud Control Panel