// Tutorial //

How To Install Django

Published on June 4, 2012
Default avatar
By Etel Sverdlov
Developer and author at DigitalOcean.
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!

If you’ve enjoyed this tutorial and our broader community, consider checking out our DigitalOcean products which can also help you achieve your development goals.

Learn more here

About the authors
Default avatar
Developer and author at DigitalOcean.

Still looking for an answer?

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!

@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

@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.