Install django in Ubuntu

Install django in Ubuntu

Sagar Sharma
Sagar Sharma

Table of Contents

Django is one of the most popular frameworks today based on Python.

But there are multiple ways to install Django and each is meant for a different purpose. And in this tutorial, I will share the following ways to install Django:

  • Install with pipx (officially recommended way)
  • Install development branch of Django (gets the most recent version)
  • Install with apt, Ubuntu's package manager  (easiest)

So let's start with the first and recommended way.

Install Django using Apt in Ubuntu (easiest)

By far this is the easiest way you can install Django in Ubuntu as you'll be using apt package manager so all you do is execute one command for the installation.

To install Django in Ubuntu, you can use the following command:

sudo apt install python3-django

If you want to verify the installation, you can check the installed version using the following command:

django-admin --version
Check installed version of Django in Ubuntu

If you visit Django's official page, then, you'd know that they recommend using Django using pip as it provides flexibility and stability.

After Pip's new feature, you will get an externally-managed environment error if you went with the straight installation.

So installing packages virtually is the only option you have.

But installing packages in the virtual environment is a lengthy task and there comes the usage of the pipx that will install packages in a virtual environment.

First, you install the pipx in Ubuntu:

sudo apt install pipx

Once you are done with the installation part, add it to the $PATH variable so you can access installed packages from anywhere in the system:

pipx ensurepath
Add pipx to the $PATH in ubuntu to install Django in ubuntu

Now, log out and log back in to use the pipx.

To install Django, you can use the following command:

pipx install django
Install Django using pipx in Ubuntu

And as you can see, it gave me Django version 4.2.4.

But what if you want to have a development branch to get the most recent packages?

If your workflow demands stability, then please avoid getting a development branch. 

Here too, I will be using the pipx. But this time, you'd have to use Git.

So first, install Git in Ubuntu using the following command:

sudo apt install git

Now, clone the Django git repository:

git clone

And finally, use the pipx to install the development branch of Django:

pipx install django/
Install development brach of Django in Ubuntu

As you can see, it gave me the latest version of Django 5.0 which is far ahead of anything I achieved with other methods.

Here's how to get the most out of pipx

If you're new to pipx and have no idea of how you install, search, upgrade, or remove packages installed through pipx, then, you can refer to our detailed guide on how to install and use pipx in Ubuntu:

Install and Use pipx in Ubuntu & Other Linux
Pipx addresses the shortcomings of the popular pip tool. Learn to install and use Pipx in Linux.

I hope you will find this guide helpful.