Here is how to install Django framework on Ubuntu 20.04 in under two minutes:
Step 0 - Install python
Before we start it is important to check if python in already installed on your system. To do that, run the following command:
python
If python is not installed on your system, install it using the following command:
sudo apt-get update && sudo apt-get install python3.10
Step 1 - Install pip
For the remaining steps, you will need pip
. Run the following command to upgrade your python version to support pip
.
python -m ensurepip --upgrade
Then download pip script from the official source.
Now, navigate to the destination, where the script was downloaded and run the following command:
python get-pip.py
Step 2 (Optional) - Create virtual environment
In this optional step, you will create a virtual environment. If you choose to skip this step, Django will be installed globally on your system.
Create the virtual environment:
python3 -m venv nameoftheenv
Activate the environment:
source nameoftheenv/bin/activate
Step 3 - Install Django
Finally, install the Django framework by running the following command:
python -m pip install Django
That’s it
You have installed the Django framework and now you are ready to build web applications on python.