Django Installation


Windows or Linux or Mac Operating System

Python[Classic Python distribution or Anaconda Python distribution]

Installation Steps

Step 1: Open a terminal and type the below command to check Django is installed already

django-admin version


(base) techlaps@techlapsws:~/my_work_area/django_workarea$ django-admin version

Command 'django-admin' not found, but can be installed with:

sudo apt install python3-django

(base) techlaps@techlapsws:~/my_work_area/django_workarea$ 

If Django is installed on your machine, then you will receive the Django version or else you will receive the command not found error like above.

Now we start installing the Django on our system/laptop/server

Before we install the Django, lets create Python virtual environment which is isolation python environment for working with Django projects which is the best practice.

Step 2: Run the below command to create a Python virtual environment

python -m venv djangovenv

Here the “djangovenv” is the new python virtual environment


(base) techlaps@techlapsws:~/my_work_area/django_workarea$ python -m venv djangovenv
(base) techlaps@techlapsws:~/my_work_area/django_workarea$

Step 3: Run the below command to activate the python virtual environment which we created above, so that we can start installing Django python package

source djangovenv/bin/activate


(base) techlaps@techlapsws:~/my_work_area/django_workarea$ source djangovenv/bin/activate
(djangovenv) (base) techlaps@techlapsws:~/my_work_area/django_workarea$ 

Step 4: Run the below command to install Django python package using pip utility

pip install django


(djangovenv) (base) techlaps@techlapsws:~/my_work_area/django_workarea$ pip install django
Collecting django
  Downloading Django-4.2.3-py3-none-any.whl (8.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.0/8.0 MB 18.4 MB/s eta 0:00:00
Collecting asgiref<4,>=3.6.0
  Downloading asgiref-3.7.2-py3-none-any.whl (24 kB)
Collecting sqlparse>=0.3.1
  Downloading sqlparse-0.4.4-py3-none-any.whl (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.2/41.2 kB 13.1 MB/s eta 0:00:00
Collecting typing-extensions>=4
  Downloading typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Installing collected packages: typing-extensions, sqlparse, asgiref, django
Successfully installed asgiref-3.7.2 django-4.2.3 sqlparse-0.4.4 typing-extensions-4.7.1

[notice] A new release of pip available: 22.3.1 -> 23.2.1
[notice] To update, run: pip install --upgrade pip
(djangovenv) (base) techlaps@techlapsws:~/my_work_area/django_workarea$ 

Step 5: If you see like above message, then Django python package is successfully installed on your system/laptop/server.

Now we can check the django-admin version command to verify the Django installation,

django-admin version


(djangovenv) (base) techlaps@techlapsws:~/my_work_area/django_workarea$ django-admin version
(djangovenv) (base) techlaps@techlapsws:~/my_work_area/django_workarea$

Leave a Reply